处理方法
First Activity的代码:
- +@Override
- protected void onListItemClick(ListView l, View v, int position, long id) {
- // TODO Auto-generated method stub
- super.onListItemClick(l, v, position, id);
- // txt.setText(items[position]);
- // Try to send the items[position] in the intent
- Intent i = new Intent(this, SecondActivity.class);
- i.putExtra("testonArray", items[position].toString());
- startActivity(i);
- }
第二个activity代码
- Bundle extras=getIntent().getExtras();
- String selected_item=extras.getString("testonArray");
- txt = (TextView) findViewById (R.id.txt2);
- txt.setText(selected_item);
原文地址:http://www.itmmd.com/201411/215.html
该文章由 萌萌的IT人 整理发布,转载须标明出处。