I looked at a few examples of tab fragments (also in Support4Demos), but I found that every time a tab is switched, a tab content presentation is created each time from the 'onCreateView' fragment class.
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.hello_world, container, false); View tv = v.findViewById(R.id.text); ((TextView)tv).setText("Fragment #" + mNum); tv.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.gallery_thumb)); return v; }
Is it possible to create kinds of fragments once, when they are first created, and will be displayed / deleted when switching between tabs instead of creating again?
source share