/** * 血糖时间选择的对话框。 */ private OnClickListener btnSelectTimeSpanListener = new OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(BloodSugarMeasurementActivity.this); builder.setTitle(getResources().getString(R.string.str_please_chose_time_to_measure_blood_sugar)) .setIcon(android.R.drawable.ic_dialog_info) .setSingleChoiceItems(SelectTimeSpanitems, 0, new DialogInterface.OnClickListener(){ @Override public void onClick(DialogInterface dialog, int which) { // mSugarTimePan = 0; mLblbtnTimeSpan.setText(SelectTimeSpanitems[which]); switch (which) { case 0://餐后1小时 mSugarTimePan = 1; txtSugerValue.setText(""); txtSugerValue.setText(getSugarTimeValue(mSugarTimePan)); break; case 1://餐后2小时 mSugarTimePan = 2; txtSugerValue.setText(""); txtSugerValue.setText(getSugarTimeValue(mSugarTimePan)); break; case 2://餐后3小时 mSugarTimePan = 3; txtSugerValue.setText(""); txtSugerValue.setText(getSugarTimeValue(mSugarTimePan)); break; default: break; } dialog.dismiss(); } }); builder.show(); } }; /** * 获取各时间段的血糖值。 */ private String getSugarTimeValue(int timepan){ ArrayList detailsList = dailyRec.getDetails(addRecTypeFlag); for (int i = 0; i < detailsList.size(); i++) { DailySugarRecDetails details = detailsList.get(i); if (timepan == details.getTimespan() ) { return String.valueOf(details.getValue()); } } return "0"; }