java - android what to use instead of onRestart() in a fragment -
i'm dealing .setvisibility() of view, inside main fragment @ app start. want view invisible on app start (for set invisible inside oncreateview) , visible when come fragment other activities while app open (and tried use onrestart() set view visible cannot resolve onrestart method) onrestart deprecated or? thanks
edit: answers below suggesting use onresume (and whom gave -1), onresume doesn't work onrestart @ all, cause being called right after oncreateview.
fragments don't have onrestart()
. it's activities.
see lifecycle of fragments below
i suppose you're looking onresume()
instead
use boolean flag check whether or not you're returning fragment:
private boolean firstvisit; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { //other stuff firstvisit = true; } @override public void onresume() { //other stuff if (firstvisit) { //do stuff first visit firstvisit = false; } }
Comments
Post a Comment