I have a list full of items, and I wanted to pass 3 of the items in another activity, then I go back to the list to go through 3 other items more ... so on (the chosen items should appear as a list).
This is my code:
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
MenuInflater inflate = getMenuInflater();
if (v.getId() == R.id.listView) {
inflate.inflate(R.menu.menu_main, menu);
}
}
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);
final Intent intent = intent3.putStringArrayListExtra("CODE", ArrayList);
intent3.putExtra("CODE", text3);
intent3.putExtra("PRODUC", text4);
intent3.putExtra("PRECIO", text5);
startActivity(intent3);
}
return true;
and the other activity that it receives ... it receives only a single row of item ... I want to add in the other activity as list all the selected items ... THANK YOU
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_carrito);
productos = new ArrayList<>();
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);
}
}