我有 todolist 应用程序,它工作正常。我可以成功添加和编辑项目到列表视图。这是我的问题。当我单击项目时,项目的数据必须通过编辑活动,但现在它是空的,就像添加新项目一样。我能做什么?
编辑项目.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.edit_item);
editText1 = (EditText) findViewById(R.id.editText1);
spinner = (Spinner) findViewById(R.id.prioritySpinner);
datePicker = (DatePicker) findViewById(R.id.datePicker);
toggleButton = (ToggleButton) findViewById(R.id.statusbutton);
editButton = (Button) findViewById(R.id.editButton);
cancelButton = (Button) findViewById(R.id.cancelButton);
editButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// ArrayList<String> b = new ArrayList<String>();
task = editText1.getText().toString();
priorityLevel = spinner.getSelectedItem().toString();
status = toggleButton.getText().toString();
int day = datePicker.getDayOfMonth();
int month = datePicker.getMonth() + 1;
int year = datePicker.getYear();
date = day + "/" + month + "/" + year;
itemList.setName(task);
itemList.setPriorityLevel(priorityLevel);
itemList.setStatus(status);
itemList.setDueDate(date);
Intent okIntent = new Intent();
okIntent.putExtra("editItem", new DataWrapper(itemList));
setResult(Activity.RESULT_OK, okIntent);
finish();
}
});