我有一个alertDialog窗口,显示简单的数组列表。每个项目都是特定命令,其中一个是“删除”选项。我希望应用程序显示另一个对话框,要求确认做出的决定。我怎么能这样做?
这是我的代码:
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setCancelable(true);
ArrayAdapter<String> adapter2 = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, items);
ListView lv = new ListView(this);
lv.setAdapter(adapter2);
builder.setView(lv);
final AlertDialog alert = builder.create();
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (position == 0) {
Intent intent = new Intent(MainActivity.this, EditSavedEventActivity.class);
intent.putExtra("EventPosition", pos);
startActivity(intent);
}
else if (position == 1) {
/**************************
I want to show the second alertDialog if this option is selected
***************************/
}
alert.dismiss();
onPause();
onResume();
}
});
alert.show();