摘要:Android - AlertDialog 選單,並處理選單項目
private Dialog createMenuDialog() {
return new AlertDialog.Builder(getActivity())
.setTitle(getString(R.string.store_select_type))
.setItems(R.array.dialog_type_list, mTypeOnClickListener).create();
}
private DialogInterface.OnClickListener mTypeOnClickListener = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
String[] items_text = getResources().getStringArray(R.array.dialog_type_list);
int[] items_id = getResources().getIntArray(R.array.type_list_id);
mTypeId = items_id[which];
mTypeText.setText(items_text[which]);
}
};