选择对话框:
final String[] formatSettingItems = {"ASCII","Hexadecimal", "Decimal"}; new AlertDialog.Builder(context).setTitle("Data Format") .setItems(formatSettingItems, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { MenuItem item = myMenu.findItem(MENU_FORMAT); if(0 == which) { inputFormat = FORMAT_ASCII; item.setTitle("Format - "+ formatSettingItems[0]); } else if(1 == which) { inputFormat = FORMAT_HEX; item.setTitle("Format - "+ formatSettingItems[1]); } else { inputFormat = FORMAT_DEC; item.setTitle("Format - "+ formatSettingItems[2]); } } }).show();
效果图:
选择后:
时间: 2024-10-09 23:07:39