I am using onSaveInstanceState(Bundle outState) and passing a int value in PutInt , but in my onActivitycreated method when i am trying to getInt then it is showing exception saying , Key android:view_state expected Bundle but value was a android.util.SparseArray. The default value was returned.
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mListView = getListView();
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
if (savedInstanceState !=null) {
mCheckedPosition = 开发者_StackOverflow中文版savedInstanceState.getInt(STATE_CHECKED_POSITION, -1);
}
..................
Here i am sending the value . it is fine here. problem is in when i am getting it.
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt(STATE_CHECKED_POSITION, mCheckedPosition);
Log.d(AppConstants.TAG,"STATE_CHECKED_POSITION"+mCheckedPosition );
}
I would put super.onSaveInstanceState(outState);
after putting int into bundle.
What is value of Your 'STATE_CHECKED_POSITION' ?
精彩评论