我想通过单击“编辑”使用上下文菜单选项获取 EditText 值。我的代码:
这是我创建的上下文菜单选项,代码:
case R.id.Edit_Note:
Intent intent2 = new Intent(this, Add_Task.class);
Cursor cursor = (Cursor) this.getListAdapter().getItem((int) info.id);
cursor.moveToPosition(itemPosition);
int content = cursor.getInt(0);
intent2.putExtra("content", content );
startActivity(intent2);
break;
这是我得到意图的地方:
title = (TextView) findViewById(R.id.Listname);
Title_Edit = (EditText)findViewById(R.id.title_Edit);
content = (TextView) findViewById(R.id.content);
Content_Edit = (EditText)findViewById(R.id.content_Edit);
duedate = (Button)findViewById(R.id.duedate);
duedatetext = (TextView)findViewById(R.id.duedatetext);
title = (TextView) findViewById(R.id.Listname);
title_Edit = (EditText)findViewById(R.id.title_Edit);
content = (TextView) findViewById(R.id.content);
content_Edit = (EditText)findViewById(R.id.content_Edit);
duedate = (Button)findViewById(R.id.duedate);
duedatetext = (TextView)findViewById(R.id.duedatetext);
Intent intent2 = getIntent();
int allcontent = intent2.getIntExtra("Content", 0);
System.out.println(allcontent + "Intent ID");
Database_Notepad db = new Database_Notepad(Add_Task.this);
Cursor c = db.GetNote(allcontent);
title_Edit.setText(c.getString(0));
content_Edit.setText(c.getString(1));
duedatetext.setText(c.getShort(2));
我收到错误cursorIndexoutofbound
::
Index 0 requested with a size of 0