android - Detecting when a fragment is on top again (has focus) -


in app, activity has container fragment. when button in fragment clicked, add new fragment container , add previous fragment backstack.

fragmenttransaction fragmenttransaction = getsupportfragmentmanager().begintransaction();     fragmenttransaction.add(r.id.primary_fragment_container, homefragmenthandler);     fragmenttransaction.addtobackstack(folderid.tostring());     fragmenttransaction.commit(); 

the result pressing closes top fragment , returns me previous fragment, how want it. there elements on fragment should refreshed @ point. when user clicks , returned previous fragment, how know refresh data within fragment? there method such onresume() scenario?

you have proper add fragments backstack:

fragmenttransaction transaction = getsupportfragmentmanager().begintransaction();              myfragment fragment = new myfragment ();     transaction.replace(r.id.primary_fragment_container, fragment).addtobackstack(null).commit(); 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -