Android的Dialog工具

移动开发 waitig 547℃ 百度已收录 0评论
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.view.View;
import android.app.Activity;
public class DialogUtil
{
    public static void showDialog(final Context ctx , String msg , boolean closeSelf)
    {
        AlertDialog.Builder builder = new AlertDialog.Builder(ctx)
            .setMessage(msg).setCancelable(false);
        if(closeSelf)
        {
            builder.setPositiveButton("确定", new OnClickListener()
            {
                public void onClick(DialogInterface dialog, int which)
                {

                    ((Activity)ctx).finish();
                }
            });        
        }
        else{
            builder.setPositiveButton("确定", null);
        }
        builder.create().show();
    }    

    public static void showDialog(Context ctx , View view){

        AlertDialog.Builder builder = new AlertDialog.Builder(ctx)
            .setView(view).setCancelable(false)
            .setPositiveButton("确定", null);
        builder.create()
            .show();
    }
}

本文由【waitig】发表在等英博客
本文固定链接:Android的Dialog工具
欢迎关注本站官方公众号,每日都有干货分享!
等英博客官方公众号
点赞 (0)分享 (0)