AlertDialog也是Android系统当中最常用的对话框之一。 程序员可以给AlertDialog对话框设置相应的信息。比如title,massage,setSingleChoiceItems,setPositiveButton,setNegativeButton等等。。
但不能直接通过AlertDialog的构造函数来生产一个AlertDialog。查看源码发现AlertDialog所有的构造方法都是protected的。
AlertDialog构造方法源码如下:
protected AlertDialog(Context context) {
super((Context)null, false, (OnCancelListener)null);
throw new RuntimeException("Stub!");
}
protected AlertDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
super((Context)null, false, (OnCancelListener)null);
throw new RuntimeException("Stub!");
}
protected AlertDialog(Context context, int themeResId) {
super((Context)null, false, (OnCancelListener)null);