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
Post a Comment