【问题标题】:Caused by: java.lang.ClassCastException: android.os.Parcelable[] cannot be cast to com.zhishi.o2o.model.ShortCut[]原因:java.lang.ClassCastException: android.os.Parcelable[] 无法转换为 com.zhishi.o2o.model.ShortCut[]
【发布时间】:2016-05-01 10:48:29
【问题描述】:
shortCuts = (ShortCut[])getArguments().getParcelableArray("shortCut");

我该如何解决这个问题?

【问题讨论】:

  • com.zhishi.o2o.model.ShortCut 是否实现 Parcelable?
  • 你在ShorCut类中实现了parcelable接口吗?

标签: android casting parcelable


【解决方案1】:

你需要实现 Parcelable 到 ShortCut 类。

喜欢

public class ShortCut implement Parcelable{
//rest of code
}

希望能帮助你理解。

【讨论】:

    【解决方案2】:

    我也有同样的问题。我对 topicstarter 的 ShortCut 类的模拟明确地实现了 Parcelable。我看到此崩溃的方法非常频繁地执行 - 在 ListFragment 的onViewCreated 中,但崩溃发生非常罕见并且不可重现......

    【讨论】:

      猜你喜欢
      • 2015-09-22
      • 1970-01-01
      • 2023-03-13
      • 1970-01-01
      • 1970-01-01
      • 2014-07-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多