我正在使用android studio上的警报应用程序。用户可以在其中创建多个警报的位置,然后为用户显示这些警报。我从此视图DisplayAlarms开始,当用户单击加号图标时,我进入CreateAlarm视图。
我可以在onCreate函数中使用时间选择器和日期选择器来获取时间和日期。
public static List<SingleAlarm> getAlarms = ArrayList<>();
/// a single alarm obj is only a calendar obj and name for now
@Override
protected void onCreate(Bundle savedInstanceState) {
final int hours=0, mins=0, years=0, months=0, dates=0;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_alarm);
button = (Button)findViewById(R.id.save);
timePicker = (TimePicker)findViewById(R.id.time);
datePicker = (DatePicker)findViewById(R.id.date);
calendar = Calendar.getInstance();
display = (TextView)findViewById(R.id.show);
timePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
@Override
public void onTimeChanged(TimePicker timePicker, int hour, int min) {
calendar.set(Calendar.HOUR, timePicker.getCurrentHour());
calendar.set(Calendar.MINUTE, timePicker.getCurrentMinute());
//display.setText(integer.toString(hours));
}
});
datePicker.setOnDateChangedListener(new DatePicker.OnDateChangedListener() {
@Override
public void onDateChanged(DatePicker datePicker, int year, int month, int day) {
calendar.set(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth());
}
});
*/
}
public void leaveAlarm(View view){
//save before leaving
display = (TextView)findViewById(R.id.show);
SingleAlarm alarm = new SingleAlarm(this.calendar,"hello");
alarms.add(alarm);
super.onBackPressed();
}
到目前为止,我已经尝试实现一个警报列表(现在的日历和名称),将警报保存在其中。现在我的两个问题是
我现在到目前为止尚未实现这一目标,有人会分享一些有关如何执行此操作的提示吗?