How to avoid recreating view on onCreate on Android?

前端 未结 11 1830
执笔经年
执笔经年 2021-01-17 22:18

I have a FragmentActivity that shows a contacts list.

Here is my onCreate method:

@Override
protected void onCreate(Bundle          


        
11条回答
  •  耶瑟儿~
    2021-01-17 22:57

    The most simple way to achieve this is to do a Nullcheck
    i.e.

    if(yourcomponent==null) {
        initializecomponent();
    }
    


    That may prevent your views from recreating.

提交回复
热议问题