显示警告对话框中的所有画面 [英] Displaying alert dialog box in all the screens

查看:132
本文介绍了显示警告对话框中的所有画面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发时,它得到一个事件,这将显示一个Alertdialog中的应用程序。 目前,警报会仅在该特定的活动。 我需要得到这个警报的所有屏幕(如主屏幕,信息屏幕等),但我在打电话。

I am developing an application which will display an Alertdialog box when it gets an event. Currently the alert will come only in that particular activity. I need to get this alert on all the screens ( eg. home screen, message screen, etc )except I am in a call.

请提供解决方案这一点。

Please provide a solution for this.

推荐答案

创建一些 utils的类的静态方法,将采用上下文作为参数,并建立整个对话。

Create some Utils class with static method that will takes Context as an argument and builds whole dialog.

编辑:

public class Utils {

    public static AlertDialog getDialog(Context context) {

        final AlertDialog.Builder builder = new AlertDialog.Builder(context);
        return builder
            .setTitle("title")
            .create()
            ;

    }

}

和调用它的每一个地方,你需要:

And call it in every place you need:

Utils.getDialog(context).show();

这篇关于显示警告对话框中的所有画面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆