Reload fragment if current tab is clicked again?

霸气de小男生 提交于 2019-12-24 06:28:35

问题


To navigate in my Android application I use ActionBar.NAVIGATION_MODE_TABS. The content in one of the tabs is changing quite fast.

A user should be able to reload the tab by touching the same item in the action bar again. Currently the tab content is cached by ViewPager and therefore not refreshed if a user clicks on the tab.

As TabListener.onTabReselected(...) is fired even if the current tab is already shown, it may be the starting point of a solution.


回答1:


As TabListener.onTabReselected(...) is fired even if the current tab is already shown, it may be the starting point of a solution.

On onTabReselected(), call a method on your existing fragment that causes it to refresh its contents.



来源:https://stackoverflow.com/questions/12876106/reload-fragment-if-current-tab-is-clicked-again

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!