显示警告对话框中的所有画面

编程入门 行业动态 更新时间:2024-10-23 19:28:42
本文介绍了显示警告对话框中的所有画面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我开发时,它得到一个事件,这将显示一个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();

更多推荐

显示警告对话框中的所有画面

本文发布于:2023-11-27 21:04:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639597.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:画面   对话框中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!