lvMsg = (ListView) findViewById(R.id.listView);
//.
//. using cursor and attach it to adapter
//.
adapter = new SimpleCursorAdapter(this, R.layout.row, c,
new String[]{"_id","address", "body"}, new int[]{
R.id.textView6, R.id.textView5, R.id.textView7});
lvMsg.setAdapter(adapter);
lvMsg.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
Intent i=new Intent(MainActivity.this,otherActivity.class);
//???message should be ??
i.putExtra( "MESSAGE" , message);
startActivity(i);
}
});
感谢...
答案 0 :(得分:1)
如果我理解你的问题......将每个textview的文本都写成字符串并发送给它......
lvMsg.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
String _id = ((TextView) view.findViewById(R.id.textView6)).getText().toString();
String address = ((TextView) view.findViewById(R.id.textView5)).getText().toString();
String body = ((TextView) view.findViewById(R.id.textView7)).getText().toString();
Intent i=new Intent(MainActivity.this,otherActivity.class);
//???message should be ??
String message = id + address + body;
i.putExtra( "MESSAGE" , message);
startActivity(i);
}
});
答案 1 :(得分:0)
如果您想通过点击它来传递每个项目值,那么
消息应该是
String message = adapter.getItem(position).toString;
编辑
String message = ((TextView)adapter.getItem(position)).getText().toString();
答案 2 :(得分:0)
尝试这个。
lvMsg.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
TextView v = (TextView) view.findViewById(R.id.R.id.textView6);
//to pass id value
Intent i=new Intent(MainActivity.this,otherActivity.class);
i.putExtra( "MESSAGE" , v.getText());
startActivity(i);
}
});