Android 如何在其他活动中传递1个或多个项目
我需要你帮我修改密码。。。我得到了一个列表视图多列的项目,我想传递其他活动中的3个项目,并保存它时,我点击任何一行。。。然后返回到所选其他行中的列表。。。一次又一次,像购物车一样Android 如何在其他活动中传递1个或多个项目,android,Android,我需要你帮我修改密码。。。我得到了一个列表视图多列的项目,我想传递其他活动中的3个项目,并保存它时,我点击任何一行。。。然后返回到所选其他行中的列表。。。一次又一次,像购物车一样 这是我的密码` public boolean onContextItemSelected(final MenuItem item) { AdapterView.AdapterContextMenuInfo info= (AdapterView.AdapterContextMenuInfo) item.getMe
这是我的密码`
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);
}
返回true
而另一个活动只接收1行
@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);
}
}
尝试使用
intent3.putStringArrayListExtra(“name”,arrayList)代码>
通过这种方式,您可以一次放入整列字符串,而不是一次放入一列。第二个活动中是否也应该有其他listview?第二个活动中应该有另一个ArrayList