这里是时间的设置:
public void setTime() { final Time t = new Time(); t.setToNow(); new TimePickerDialog(HelperMain.this, new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { String time ; if(hourOfDay > 12) { if((hourOfDay - 12) >= 10) { time = (hourOfDay - 12) + " : " + minute + " pm" ; } else { time = "0" + (hourOfDay - 12) + " : " + minute + " pm" ; } } else if(hourOfDay == 12) { time = hourOfDay + " : " + minute + " pm" ; }else { if(hourOfDay >= 10){ time = hourOfDay + " : " + minute + " am" ; } else { time = "0" + hourOfDay + " : " + minute + " am" ; } } //calendar.setTimeInMillis(System.currentTimeMillis()); calendar.set(t.year,t.month,t.monthDay,hourOfDay,minute,0); timeShow.setText(time); SharedPreferences uiState = getPreferences(0); SharedPreferences.Editor editor = uiState.edit(); editor.putString("time", time); //一定要记得在存入数据之后要调用commit方法,不然getXXX的时候会获取不到值 editor.commit(); if(helper) { openHelper(); onOffShow.setText("开"); } } }, t.hour, t.minute, false).show(); }到这里就完成了开关,时间和回复内容的设置。