[英]android intents - passing data
How to pass and get "myobject1" between two activities? 如何在两个活动之间传递和获取“ myobject1”?
First activity: 第一次活动:
private ArrayList<Custom> myobject1 = new ArrayList<Custom>();
...
i.putExtra("myobject1", myobject1);
Second activity: 第二项活动:
results =(ArrayList<Custom>) getIntent().getSerializableExtra("myobject1");
Here is my Custom.class : 这是我的Custom.class:
public class Custom implements Comparable<Custom>{
private String big;
private String small;
public Custom(String n,String d)
{
big = n;
small = d;
}
public String getFirst()
{
return big;
}
public String getSecond()
{
return small;
}
@Override
public int compareTo(Custom o) {
if(this.big != null)
return this.big.toLowerCase().compareTo(o.getFirst().toLowerCase());
else
throw new IllegalArgumentException();
}
}
At this moment I'm getting error: E/AndroidRuntime(8032): java.lang.RuntimeException: Parcel: unable to marshal value 目前,我收到错误消息:E / AndroidRuntime(8032):java.lang.RuntimeException:地块:无法编组值
In order to pass a value from an Activity
to another the Class
of the object you try to pass should implement the Parcelable
interface. 为了将一个值从一个
Activity
传递给另一个,您尝试传递的对象的Class
应该实现Parcelable
接口。 You can find more info here http://developer.android.com/reference/android/os/Parcelable.html . 您可以在http://developer.android.com/reference/android/os/Parcelable.html上找到更多信息。 In case you need anything more specific, please shoot it!
如果您需要更具体的内容,请进行拍摄!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.