将 `TransformingRandomAccessList<T>` 转换为 `List<T>`
Convert a `TransformingRandomAccessList<T>` to just `List<T>`
调用Lists.transform
后,我们得到一个TransformingRandomAccessList
。很棒,只是在尝试打包时出现异常崩溃:
Caused by: org.parceler.ParcelerRuntimeException: Unable to find generated Parcelable class for com.google.common.collect.Lists$TransformingRandomAccessList, verify that your class is configured properly and that the Parcelable class com.google.common.collect.Lists$TransformingRandomAccessList$$Parcelable is generated by Parceler.
List<Foo> items = List.transform(...);
Bundle bundle = new Bundle();
bundle.putParcelable("MyItemsKey", Parcels.wrap(items));
任何快速和容易地转换 items
到普通列表。或者是否有更好的方法将其放入 Bundle
?
我会用这个:
ImmutableList.copyOf(items);
另一种选择是使用 java 库中的那个
new ArrayList<Foo>(items);
调用Lists.transform
后,我们得到一个TransformingRandomAccessList
。很棒,只是在尝试打包时出现异常崩溃:
Caused by: org.parceler.ParcelerRuntimeException: Unable to find generated Parcelable class for com.google.common.collect.Lists$TransformingRandomAccessList, verify that your class is configured properly and that the Parcelable class com.google.common.collect.Lists$TransformingRandomAccessList$$Parcelable is generated by Parceler.
List<Foo> items = List.transform(...);
Bundle bundle = new Bundle();
bundle.putParcelable("MyItemsKey", Parcels.wrap(items));
任何快速和容易地转换 items
到普通列表。或者是否有更好的方法将其放入 Bundle
?
我会用这个:
ImmutableList.copyOf(items);
另一种选择是使用 java 库中的那个
new ArrayList<Foo>(items);