這裏是我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項目。
任何建議,將不勝感激請,因爲我已經做了研究,這一點,仍然還沒有找到一個合適的答案
可能的重複[如何在Android應用程序中的活動之間傳遞數據?](https://stackoverflow.com/questions/2091465/how-do-i-pass-data-between-activities -in-android-application) – Zoe