Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between onTabSelected() and onTabReselected()?

I am creating an app where creating tabs using FragmentPagerAdapter. When first time the tabs will be loaded by default the 1st tab will be selected. But after switch to another tab when user will return on the first tab again it will check some data in database and based on the data it will show content on first tab. So I am not sure where I should call the function to check in database? onTabSelected() or onTabReselected()?

like image 874
ray Avatar asked Feb 27 '13 08:02

ray


1 Answers

onTabReselected : Called when a tab that is already selected is chosen again by the user. Some applications may use this action to return to the top level of a category.

and

onTabSelected : is called when a tab enters the selected state (it's previous state was unselected).

you should just keep a member variable as a counter and in onTabSelected when the specified tab is selected the second time do what you want.

like image 57
Mouna Cheikhna Avatar answered Nov 29 '22 19:11

Mouna Cheikhna