我正在创建一个应用程序,如果用户选择了一个 子菜单项我弹出一个警告对话框,询问他的确认 他是否希望将该项目保存在他的列表中并保存 如果按下否,则按是,不添加。
答案 0 :(得分:1)
您可以使用它来显示警告:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Are you sure to do this?").setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
doSomeThing();
dialog.cancel();
}
}).setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
答案 1 :(得分:0)
您可以将从对话框中获得的元素添加到用于馈送Adapter
然后提供cursor = new yourAdapter(YourClass.this.getBaseContext(), android.R.layout.simple_list_item_1, dataList);
调用cursor.notifyDataSetChanged();
告诉列表重新填充新数据;