How to maintain fragment's state in the application

前端 未结 4 1828
长情又很酷
长情又很酷 2020-12-09 22:01

How to maintain fragment\'s state when it is shown within FragmentTabHost?

Thanks to this tutorial, I\'m able to implement FragmentTabHost in my applica

4条回答
  •  甜味超标
    2020-12-09 22:47

    Had the same thing in my app. You will need to copy the FragmentTabHost to your project, point your code to use the new custom FragmentTabHost and then change the code of doTabChanged to following implementation:

        private FragmentTransaction doTabChanged(String tabId, FragmentTransaction ft) {
        TabInfo newTab = null;
        for (int i=0; i

    The change that was made is that instead of deattach/attach the fragment, we are doing hide/show

提交回复
热议问题