从不同rowView(S)多ListView的文本,并将它们传递到下一个页面

从不同rowView(S)多ListView的文本,并将它们传递到下一个页面

问题描述:

这里是我menu.java类从不同rowView(S)多ListView的文本,并将它们传递到下一个页面

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; 
    } 

这里是我的适配器类

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); 

在接收类我已经声明

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

我已经创建了一个带有ImageView的三个textViews(tvType,tvDescripti一个自定义的ListView on,tvPrice)。当用户点击listView项目后,必须将tvType传递给下一个活动时,我遇到了问题。似乎我只能使用putExtra intent一次传递一个项目。我想通过多个项目不是一个。

我应该能够在按下按钮之后启动下一个活动之前选择尽可能多的项目。 一旦出现,那么应显示所有我选择的tvType项目。

任何建议,将不胜感激请,因为我已经做了研究,这一点,仍然还没有找到一个合适的答案

+2

可能的重复[如何在Android应用程序中的活动之间传递数据?](https://*.com/questions/2091465/how-do-i-pass-data-between-activities -in-android-application) – Zoe

使用下面的代码,来传递数据

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

你知道代码即可获得下一个活动的数据

+0

您的输入被赞赏ysl ...是的,我设法找出了一个 – kamo