【发布时间】:2016-03-29 09:25:10
【问题描述】:
【问题讨论】:
标签: android material-design dialog
【问题讨论】:
标签: android material-design dialog
试试下面的代码:
从资源中获取数组(你可以使用arraylist或任何数组)
final String[] mTestArray = getResources().getStringArray(R.array.hours_array);
用于警告对话框
new AlertDialog.Builder(MainActivity.this)
.setTitle(getString(R.string.app_name))
.setSingleChoiceItems(mTestArray, 0, null)
.setPositiveButton(R.string.txt_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
int selectedPosition = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
}
})
.setNegativeButton(R.string.txt_cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// do nothing
}
})
.show();
【讨论】: