Base class for Dialogs.
子类 AlertDialog
A subclass of Dialog that can display one, two or three buttons. If you only want to display a String in this dialog box, use the setMessage() method.
If you want to display a more complex view.
内部嵌套类 AlertDialog.Builder
AlertDialog.Builder dialog=new AlertDialog.Builder(mContext);
dialog.setTitle("");
dialog.setMessage("");
dialog.setPositiveButton("",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface,int i) {
}
});
dialog.show();
// dialog.setNegativeButton();
// dialog.setNeutralButton();
int checkedItem =0;
String items[]=new String[]{"a,b,c"};
// params: 选项,默认选中,点击监听
dialog.setSingleChoiceItems(items, checkedItem,new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface,int i) {
// dialogInterface.dismiss();
}
});
String items2[]=new String[]{"a,b,c"};
boolean[] checkedItem2={false,false,false};
// params: 选项,默认选中,点击监听
dialog.setMultiChoiceItems(items2, checkedItem2,new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialogInterface,int i,boolean b) {
// dialogInterface.dismiss();
}
});