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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

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

android - How to create dynamically Fragment pager adapter -