如何使其出现在调用它的屏幕类上而不是出现在新屏幕上

发布于 2024-12-08 20:34:55 字数 959 浏览 2 评论 0原文

我有这段代码,希望它出现在调用它的类的页面上,而不总是创建一个新的空黑色页面。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柠栀 2024-12-15 20:34:55

我检查了您的代码,您的对话框显示背景为黑屏。我想你想删除后台的黑屏,如果我错了请告诉我。

要从警报对话框的背景中删除黑屏,请在清单文件的活动标记中添加以下内容:

android:theme="@android:style/Theme.NoDisplay"

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 your activity tag in the manifest file add this:

android:theme="@android:style/Theme.NoDisplay"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文