我正在使用显示应用程序开始处的菜单的警告对话框,我希望对话框向我显示2个值,它们是来自对象的“名称”,以下是警报的代码对话:在AlertDialog中显示列表
public void showDialog() {
EntityType en = new EntityType();
ArrayList array = ApplicationController.entities;
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Pick one");
builder.setItems(array, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// I want to write my code here
}
});
builder.show();
}
EntityType
是我的对象,它包含一个字符串“名”和ApplicationController.entities
包含数组