我有一个 ListView,其中每个 ListItem 的布局中有 2 个 TextView。单击 ListItem 时,我想将这些 TextViews 的值传递给另一个活动。我所有的尝试都失败了,所以我问你我该怎么做?如何传递 SQLite ROW_ID、R.id.text1 和 R.id.text2 的值?
Cursor cursor = database.getAllNames();
adapter = new SimpleCursorAdapter(this, R.layout.listrow, cursor,
new String[] { Database.KEY_DATE , Database.KEY_NAME },
new int[] {R.id.text1, R.id.text2}, 0);
listView = (ListView) findViewById(R.id.list);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(SendingData.this, ReceivingData.class);
intent.putExtra("id", id); //this should pass the SQLite ROW_ID
intent.putExtra("date", date); //this should pass the value of R.id.text1
intent.putExtra("name", name); //this should pass the value of R.id.text2
startActivity(intent);
}
});