我想向用户显示确认对话框,当用户点击是按钮打开列表视图进行选择时。
答案 0 :(得分:0)
你可以这样
Listview.setOnItemClickListener(new AdapterView.OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
build = new AlertDialog.Builder(YourActivity.this);
build.setTitle("Title name");
build.setMessage("?");
build.setPositiveButton("Yes", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
//IF yes button pressed then write here
}
dialog.cancel();
}
});
build.setNegativeButton("No", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
dialog.cancel();
}
});
AlertDialog alert = build.create();
alert.show();
return true;
}
});
答案 1 :(得分:0)
使用此链接..............................
http://rajeshvijayakumar.blogspot.in/2013/04/alert-dialog-dialog-with-item-list.html