开发者

how to display one popup window in all activitys?

Developing sample download application,My application contains 3 activities.When the first activity starts, the download begins automatically. when the download is completed I have set a code to raise a popup.Will the same popup raises in the all other activities also.Please let me know if I need to put any code to get the popup in the other a开发者_JAVA百科ctivities too.pls tell me how to do this.


here is sample code code of using AlertDialog in all activity.

crate one class file like as allmethod.java

and add this code in that class

public static void showAlert(Activity act,String msg)
        {
            AlertDialog.Builder alert = new AlertDialog.Builder(act);
            alert.setMessage(msg).setPositiveButton("OK", new OnClickListener(){
                @Override
                public void onClick(DialogInterface dialog, int which)
                {   
                }
            }).show();
        }

and you can use from any class like as

allmethod.showAlert(Activity,"Message");

if you want PopUp instead of AlertDialog then you can write your code in showAlert Method and you can also add parameters whatever you need.


If you want the same pop up to be shown in all the 3 activities then you should make one Base Activity and put your pop up code here and extend it in all your 3 activities and now you can call it directly from your code...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜