-2

Here is my menu.java class

public class menu {

    private String type;
    private String description;
    private double price;

    public menu(String type, String description, double price) {
        this.type = type;
        this.description = description;
        this.price = price;
    }
    public String getType() {
        return type;
    }
    public String getDescription() {
        return description;
    }
    public double getPrice() {
        return price;
    }

And here is my Adapter class

public class menuItems extends AppCompatActivity {
    ListView listItems;
    TextView textView6;
    ArrayList<menu> list;
    List selections=new ArrayList();
    int count=0;

        listItems = (ListView) findViewById(R.id.listItems);
        textView6 = (TextView) findViewById(R.id.textView6);
        list = new ArrayList<>();

        final menu menu1 = new menu("GrayHound", "Atchaar,Chips,2 
polony,cheese,beef patty,russian and egg", 32.00);
        menu menu2 = new menu("Hummer", "Atchaar,chips,polony,cheese,beef 
patty,russian and egg", 26.00);

        list.add(menu1);
        list.add(menu2);

        final ProductAdapter2 adapter = new ProductAdapter2(this, list);
        listItems.setAdapter(adapter);

    private void doSomethingWithItems(){
        TextView tv = (TextView) findViewById(R.id.tvType);   
        String string = tv.getText().toString();
        Intent intent= new Intent(menuItems.this,items.class);
        intent.putExtra("user",string);
        startActivity(intent);

In the receiving class I've declared

 Bundle value=getIntents().getExtras().
 String pass=value.toString("user");
 textView15.setText(value); 

I have created a custom listView with an ImageView and three textViews(tvType,tvDescription,tvPrice).I am getting a problem when I have to pass the tvType to the next activity after the user has clicked on the listView item.It seems I can only pass one item at a time using putExtra intent.I want to pass multiple items not one.

I should be able to select as many items as I want before launching the next activity after pressing of a button. And once there,then all my selected tvType items should be shown.

Any suggestion would be appreciated please,as I have done research into this and still havent found a suitable answer

Toastrackenigma
  • 7,604
  • 4
  • 45
  • 55
kamo
  • 1
  • 2
  • 2
    Possible duplicate of [How do I pass data between Activities in Android application?](https://stackoverflow.com/questions/2091465/how-do-i-pass-data-between-activities-in-android-application) – Zoe Oct 08 '17 at 09:42

1 Answers1

0

Use Following code , To pass the data

                Bundle bundle = new Bundle();
                bundle.putString("firstString",strFirst);
                bundle.putString("secondString",strSecond);
                bundle.putString("thirdString",strThird);
                intent.putExtra("bundle",bundle);

You know the code to get the data on next activity

yogesh lokhande
  • 1,245
  • 1
  • 11
  • 20