Button.OnClickListener myShowAlertDialog = new Button.OnClickListener() { |
public void onClick(View arg0) { |
new AlertDialog.Builder(EX03_20. this ) |
.setTitle(R.string.str_alert_title) |
.setItems(R.array.items_irdc_dialog, // 这是一个array |
new DialogInterface.OnClickListener() { |
public void onClick(DialogInterface dialog, |
int whichcountry) { // 检测按了哪个item |
CharSequence strDialogBody = getString(R.string.str_alert_body); |
String[] aryShop = getResources() |
.getStringArray( |
R.array.items_irdc_dialog); |
new AlertDialog.Builder(EX03_20. this ) |
.setMessage( |
strDialogBody |
+ aryShop[whichcountry]) |
.setNeutralButton( |
R.string.str_ok, |
new DialogInterface.OnClickListener() { |
public void onClick( |
DialogInterface dialog, |
int whichButton) { /* 在这里处理要作的事 */ |
} |
}).show(); |
} |
}) |
.setNegativeButton( "取消" , |
new DialogInterface.OnClickListener() { |
public void onClick(DialogInterface d, int which) { |
d.dismiss(); |
} |
}).show(); |
} /* End: public void onClick(View arg0) */ |
}; |