not run oncreate() ,on tab change in same page, 2nd time

后端 未结 2 1730
独厮守ぢ
独厮守ぢ 2021-01-23 22:07

I have 4 tabs in a page view when i click first time on tab it executes it oncreate() method of corresponding tab and when i go to other tab on same page and again

2条回答
  •  别那么骄傲
    2021-01-23 22:36

    In the android oncreate() lifecycle called once in life of the activity (like constructor), as you press again that time the activity is alive and in memory so it will not call onCreate again.

    so you have to implement

    TabHost.setOnTabChangedListener(TabHost.OnTabChangeListener l).
    

提交回复
热议问题