如何使其出现在调用它的屏幕类上而不是出现在新屏幕上
我有这段代码,希望它出现在调用它的类的页面上,而不总是创建一个新的空黑色页面。
public class AlertAndCallUtility extends Activity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AlertDialog alertDialog = new AlertDialog.Builder(AlertAndCallUtility.this).create();
alertDialog.setTitle("Reset...");
alertDialog.setMessage("R u sure?");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_CALL);
String phoneNumber = "0123456";
intent.setData(Uri.parse("tel:" + Uri.encode(phoneNumber)));
startActivity(intent);
} });
alertDialog.setIcon(R.drawable.icon);
alertDialog.show();
}
我需要改变什么?
非常感谢
I have this code and would like it to appear on the page of the class it's called from and not always creates a new empty black page.
public class AlertAndCallUtility extends Activity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AlertDialog alertDialog = new AlertDialog.Builder(AlertAndCallUtility.this).create();
alertDialog.setTitle("Reset...");
alertDialog.setMessage("R u sure?");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_CALL);
String phoneNumber = "0123456";
intent.setData(Uri.parse("tel:" + Uri.encode(phoneNumber)));
startActivity(intent);
} });
alertDialog.setIcon(R.drawable.icon);
alertDialog.show();
}
What do I need to change?
Many thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我检查了您的代码,您的对话框显示
背景为黑屏
。我想你想删除后台的黑屏,如果我错了请告诉我。要从警报对话框的背景中删除黑屏,请在清单文件的
活动标记
中添加以下内容:I checked your code and your dialog is showing with
black screen in the background
. I guess you want to remove this black screen in the background if I am wrong let me know.To remove the
black screen from the background
of the alert dialog, in youractivity tag in the manifest
file add this: