我有一个对象的ArrayList,如下所示:ArrayList<ObjectName>
。
我想将它传递到一个新的Activity
中。 我尝试使用putParcelableArrayList
,但它对对象存在问题。 我从变量创建中删除了<ObjectName>
部分,这种方法可以工作,但是然后我得到了Eclipse complaining about unsafe stuff的错误。
如何将这个ArrayList<ObjectName>
传递到新的Activity中?
感谢您的时间。
编辑
ArrayList<ObjectName> arraylist = new Arraylist<ObjectName>();
Bundle bundle = new Bundle();
bundle.putParcelableArrayList("arraylist", arraylist);
我遇到了以下错误:
The method `putParcelableArrayList(String, ArrayList<? extends Parcelable>)` in the type `Bundle` is not applicable for the arguments `(String, ArrayList<ObjectName>)`
编辑2
对象示例代码。我需要更改它才能使Parcelable
工作吗?
public class ObjectName {
private int value1;
private int value2;
private int value3;
public ObjectName (int pValue1, int pValue2, int Value3) {
value1 = pValue1;
value2 = pValue2;
value3 = pValue3;
}
// Get Statements for each value below
public int getValue1() {
return value1;
}
// etc