Android Fragments Best usage for memory

49 views Asked by At

I have a Main Activity with 5-tabs (like Instagram) and because I didn't want to load each of them everytime the user clicks a tab , I used and set the "set Screen Page Limit" command to 5. However , I understand it is very heavy for memory . What I've seen a just few seconds ago on the facebook app is that it doesn't auto load the content of all tabs but every tab's content loads when you visit it and by the time a tab is loaded , next time you visit the specific tab , it doesn't load again. How can we achieve like this ? Thanks!

1

There are 1 answers

0
Khushvinder On

First you need to enable cache in api library Like use volley network api. and all operation start onCreate() method like

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new ArrayAdapter(getActivity(),android.R.layout.simple_list_item_activated_1, android.R.id.text1, DummyContent.ITEMS)); }

because its called once and second time this method will get called and you will get your data as its on second visit.