activity_main_01.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/btnMultiple"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="多列表对话框">
</LinearLayout>
MainActivity.java:
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_main_02);
Button btnMultiple = this.findViewById(R.id.btnMultiple);
btnMultiple.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
AlterDialog.Builder builder = new AlterDialog.Builder(MainActivity.this);
final String dialogs[] = {"置顶聊天","标题未读","删除该聊天"};
builder.setItems (dialogs,new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog,int which){
Toast.MakeText(MainActivity.this,"你的选项是:"+dialogs[which],Toast.LENGTH.SHORT()).show();
}
});
builder.show();
}
});
}