我需要一只手拿着我的代码...我有一个listview多列的项目,我想在其他活动中传递3项,并在我点击任意一行时保存...然后返回到列表在选定的其他行...再次,一次又一次像购物车一样 这是我的代码`
public boolean onContextItemSelected(final MenuItem item) {
AdapterView.AdapterContextMenuInfo info= (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
GetContacts get = new GetContacts();
String datas=get.doInBackground().toString();
Log.d("RESULT",datas);
int id = info.position;
View view=info.targetView;
switch (item.getItemId()) {
case R.id.iva:
TextView textView3 = (TextView) view.findViewById(R.id.txtCodigo);
TextView textView4 = (TextView) view.findViewById(R.id.txtDescrip);
TextView textView5 = (TextView) view.findViewById(R.id.txtPrecio);
String text3 = textView3.getText().toString();
String text4 = textView4.getText().toString();
String text5 = textView5.getText().toString();
Intent intent3= new Intent(busqueda.this,Carrito.class);
intent3.putExtra("CODE",text3);
intent3.putExtra("PRODUC",text4);
intent3.putExtra("PRECIO",text5);
startActivity(intent3);
}
return true;
另一个活动只收到一行......
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_carrito);
texto=(TextView)findViewById(R.id.textView3);
txtcod=(TextView)findViewById(R.id.textView4);
txtpre=(TextView)findViewById(R.id.textView5);
final Intent intent = getIntent();
Bundle extra = intent.getExtras();
if (extra != null) {
String dato = extra.getString("CODE");
String Tok = extra.getString("PRODUC");
String Token2 = extra.getString("PRECIO");
texto.setText(dato);
txtcod.setText(Tok);
txtpre.setText(Token2);
}
}
答案 0 :(得分:0)
尝试使用intent3.putStringArrayListExtra("name", arrayList);
这样,您可以将整列字符串放在一次,而不是一次放入一列。