任何人帮助我...如何在启动时设置带有警报对话框的检查默认单选按钮..?
这是我的代码,例如:我想在启动时设置单选按钮,其中项目为“15”
public void showDialog()
{
final CharSequence[] items = {"5", "10", "15","20"};
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
alertDialogBuilder.setTitle("Set limit article");
alertDialogBuilder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Toast.makeText(SettingAppDisplay.this, "You selected item No." + item + ": " + items[item], Toast.LENGTH_SHORT).show();
if (items[item].equals("5")) {
//do what you want
}
else if (items[item].equals("10")) {
//do what you want
}
else if (items[item].equals("15")) {
//do what you want
}
else if (items[item].equals("20")) {
//do what you want
}
dialog.dismiss();
}
});
alertDialogBuilder.show();
}
谢谢你的参与..对不起我的英语:)