我想使项目列表动态,所以我可以在运行时添加到它,但我不知道。 CharSeqence不是动态的,也不知道如何使用适配器选项,我怎么能改变我的代码是动态的?动态alertdialog单选按钮
private void alertDialogLoadFile() {
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Choose:");
CharSequence[] items = { "moshe", "yosi", "ee" };
alert.setSingleChoiceItems(m_items , -1, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item){
/* User clicked on a radio button do some stuff */
}
});
alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
});
alert.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog ad = alert.create();
ad.show();
}
你是什么意思动态?你想在运行时让选项变化吗?谁在决定什么是选择? – 2010-01-29 18:41:08
我希望它们能够在运行时创建,就像那些选择正在从某个数据库中恢复,因此您无法选择哪些项目将在警报对话框中。 – rayman 2010-01-30 15:52:11