开发者

I want to restore my orientation in fragment.

开发者 https://www.devze.com 2023-03-24 13:49 出处:网络
I am using onSaveInstanceState(Bundle outState) andpassing a int value in PutInt , but in my onActivitycreated methodwhen i am trying to getInt then it is showing exception saying , Key android:view_s

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' ?

0

精彩评论

暂无评论...
验证码 换一张
取 消