onclick 메소드를 통해 다른 Activity에 Intent를 통해 전달해야하는 객체가 있습니다.Intent를 통해 Activity에 객체를 포함하는 객체 전달
나는이 대답을 여기에 따르고있다 How to send an object from one Android Activity to another using Intents? 잘 작동하지만 그 안에는 내 개체가있다. 개체의 배열.
개체 배열과 함께이 개체를 전달하는 방법은 무엇입니까? 다음은
는목록 (전달되는 객체)
public class ListItem {
private String title;
private String decription;
private String site;
private int price;
public void setTitle(String title) {
this.title = title;
}
public void setDecription(String d){
this.decription = d;
}
public void setSite(String s){
this.site = s;
}
public void setPrice(int i){
this.price = i;
}
public String getTitle(){
return title;
}
public String getDecription(){
return decription;
}
public String getSite(){
return site;
}
public int getPrice(){
return price;
}
}
그래서 어떻게 ArrayList의를 보낼 목록에 Parcelable을 사용
public class List {
private String Name;
private ArrayList<ListItem> items;
public List(){
items = new ArrayList<ListItem>();
}
public void addItem(String title, String d, String s, int p){
ListItem i = new ListItem();
i.setDecription(d);
i.setPrice(p);
i.setSite(s);
i.setTitle(title);
items.add(i);
}
public String getName() {
return Name;
}
public void setName(String Name) {
this.Name = Name;
}
public int getCount() {
return items.size();
}
public ArrayList<ListItem> getList(){
return items;
}
}
을 ListItem을 Parcelable
을 사용하기 전에 클래스입니다 게다가.THank 당신과 당신이 더 많은 정보가 필요하면 문의하십시오!
자신의 유형으로 목록을 사용해서는 안됩니다. 그것은 자바 표준 라이브러리 인터페이스입니다. – VM4
Google에 대한 답변이 수천 가지입니다. 하나의 : http://stackoverflow.com/questions/7181526/example-of-implementing-parcelable – VM4
@VM 좋은 포인트는 이름을 바꿔야하고, 커스텀 오브젝트 배열리스트를 파싱하는 것을 찾을 수 없다. –