嘿伙计们,我有一个ListView in" main"使用DataTimePickerDialog.class,我想从这个类中将项目添加到" activity_notification"中的ListView。使用notification.class,这是main.xml和我的代码的图片:请帮助enter image description here
public class DateTimePickerDemo extends Activity implements OnClickListener, DateTimePickerDialog.DateTimeListener {
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
findViewById(R.id.ButtonTime).setOnClickListener(this);
}
@Override
public void onClick(View view) {
// TODO Auto-generated method stub
if (view.getId() == R.id.ButtonTime)
showDateTimeDialog();
}
private void showDateTimeDialog() {
DateTimePickerDialog pickerDialog = new DateTimePickerDialog(this, false, this);
pickerDialog.show();
}
@Override
public void onDateTimeSelected(int year, int month, int day, int hour, int min, int am_pm) {
String text = day + "/" + month + "/" + year + " - " + hour + ":" + min;
if (am_pm != -1)
text = text + (am_pm == Calendar.AM ? "AM" : "PM");
((TextView) findViewById(R.id.Date)).setText(text);
}