AlertDialog.Builder builder =
new
AlertDialog.Builder(MainMenuActivity.
this
);
builder.setTitle(R.string.branch_select);
String[]items =
new
String[branches.size()];
for
(
int
i =
0
; i < branches.size(); i++) {
GetCrewResult.Branch b = branches.get(i);
items[i] = String.format(
"%s (%s)"
, b.getName(), b.getCode());
}
builder.setItems(items,
new
DialogInterface.OnClickListener() {
@Override
public
void
onClick(DialogInterface dialog,
int
which) {
CPreferences.setIntPref(Config.PREF_UIVALUE, Config.PREF_KEY_MMNENU_BRANCHIDX, which);
GetCrewResult.Branch b = branches.get(which);
Toast.makeText(getApplication(),
"SET: "
+ items[which], Toast.LENGTH_SHORT).show();
onBtnRefreshClicked();
}
});
builder.setNegativeButton(
"취소"
,
new
DialogInterface.OnClickListener() {
@Override
public
void
onClick(DialogInterface dialog,
int
which) {
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();