Tablet Screen Orientation Change - No View found for id for Fragment

前端 未结 3 585
温柔的废话
温柔的废话 2021-01-04 23:57

I have looked at questions related to my problem on SO but couldn\'t figure out what the problem is. Bear with me if this is a repost.

Here is what i am looking for:

3条回答
  •  生来不讨喜
    2021-01-05 00:34

    Change the code,

    if ((findViewById(R.id.fragment_container) != null)
                && (findViewById(R.id.detail_fragment_container) != null)) {
            mTwoPane = true;
        } else {
            mTwoPane = false;
        }
    

    by

    if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE){
        //Do some stuff
    mTwoPane = true;
    } else{
     mTwoPane = false;
    }
    

    hope it will help you

提交回复
热议问题