How to avoid recreating view on onCreate on Android?

前端 未结 11 1839
执笔经年
执笔经年 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:54

    Its simple. follow these steps in your Activity

    • Declare your listview object and listview_adapter object in side your Activity class.
    • Initialise your listview object and listview_adapter object in OnCreate() method and add the contents in your displayContacts().

    Then definitely you wont get content replication.

提交回复
热议问题