Android : Tabbed Fragment Activity creates unnecessary tabs for no reason?

on Saturday, September 20, 2014


i download the EffectiveNavitaion.zip project from here and started tinkering with it,


on 'DemoObjectFragment' i added a counter outside the function:



static int count =0


and i changed one line in OnCreateView()



((TextView) rootView.findViewById(android.R.id.text1)).setText(
(savedInstanceState == null ? "null" : "restored") + count++);


i noticed that when i swipe between alternating tabs for example (1,2,3,2,3,2,3), the tabs don't change (their count number remains the same) and we are seeing the old tab that was never destroyed


although onCreateView() on DemoObjectFragment keeps being called every swipe and it seems a new Fragment is being created every swipe and ends up not being used at all,


my question is: is there a reason for the behavior i am seeing or is there a problem in the code?


0 comments:

Post a Comment