Saturday, 15 September 2012

android - How to get notified (and able to cancel) when switching tabs -



android - How to get notified (and able to cancel) when switching tabs -

background

i have viewpager , tabhost used navigate between pages.

on cases , fragment within viewpager want disallow navigating , , show dialog inquire user verify changes done in fragment canceled .

if user confirmed , allow navigating , , if not , disallow it.

the problem

i need notified when user attempts navigate tab , , (under conditions i've created) disallow/allow .

what i've tried

the functionality i've found how disable switching .

for viewpager , utilize :

mviewpager.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(final view v, final motionevent event) { homecoming !mistabsswitchingenabled; } });

and tabhost , use:

mtabhost.gettabwidget().setenabled(mistabsswitchingenabled);

however , need quite different - need capture event of starting navigate , , able tell if allow or not .

the question

how should solve problem ?

how can notified when starting navigate , , cancel if needed ?

you should utilize tabtabhost.ontabchangelistener

android tabs navigation android-viewpager android-tabhost

No comments:

Post a Comment