美文网首页
AlertDialog工具类

AlertDialog工具类

作者: 许宏川 | 来源:发表于2016-06-29 19:37 被阅读156次
    public class DialogUtil {
    
        public static void showSingleDialog(Context context, String title, String msg, String positive,
                                            DialogInterface.OnClickListener listener) {
            createSingleDialog(context, title, msg, positive, listener).show();
        }
    
        public static void showDoubleDialog(Context context, String title, String msg, String positive,
                                            String negative, DialogInterface.OnClickListener listener) {
    
            createDoubleDialog(context, title, msg, positive, negative, listener).show();
        }
    
        public static AlertDialog createSingleDialog(Context context, String title, String msg, String positive,
                                                     DialogInterface.OnClickListener listener) {
    
            AlertDialog dialog = new AlertDialog.Builder(context)
                    .setTitle(title)
                    .setMessage(msg)
                    .setPositiveButton(positive, listener)
                    .create();
            return dialog;
        }
    
        public static AlertDialog createDoubleDialog(Context context, String title, String msg, String positive,
                                                     String negative, DialogInterface.OnClickListener listener) {
    
            AlertDialog dialog = new AlertDialog.Builder(context)
                    .setTitle(title)
                    .setMessage(msg)
                    .setPositiveButton(positive, listener)
                    .setNegativeButton(negative, listener)
                    .create();
            return dialog;
        }
    }
    
    

    相关文章

      网友评论

          本文标题:AlertDialog工具类

          本文链接:https://www.haomeiwen.com/subject/isexjttx.html