Handle Fragment duplication on Screen Rotate (with sample code)

后端 未结 4 1938
死守一世寂寞
死守一世寂寞 2021-02-06 11:03

There are some similar answers, but not to this situation.


My situation is simple.

I have an Activity with two different layouts, one in Portrait,

4条回答
  •  北荒
    北荒 (楼主)
    2021-02-06 11:10

    The correct way to handle this is to put the following in your onCreate()

    if (savedInstanceState == null) {
         // Do fragment transaction.
    }
    

提交回复
热议问题