私は を持っていて、それを自分のアクティビティのメソッドSparseArray<myObject>
でバンドルに保存し、 にonSaveInstanceState
復元したいと考えていoncreate
ます。putSparseParcelableArray
SparseArray をバンドルに入れるメソッドを見つけ、メソッドでこれを行いましたonSaveInstanceState
。
bundle.putSparseParcelableArray("mySparseArray", mySparseArray);
しかし、Eclipseはこのエラーを示しています:
The method putSparseParcelableArray(String, SparseArray<? extends Parcelable>) in the type Bundle is not applicable for the arguments (String, SparseArray<myObject>)
そして、クイックフィックスは引数mySparsArray
をSparseArray<? extends Parcelable>
にキャストしていますが、そうしてonCreateメソッドで取得すると:
mySparseArray = (SparseArray<myObject>) savedInstanceState.getSparseParcelableArray("mySparseArray");
次のエラーが発生します。
Cannot cast from SparseArray<Parcelable> to SparseArray<myObject>
この方法が間違っている場合、 mySparseArray をバンドルに入れるための解決策は何ですか? どんな助けでも大歓迎です。