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

enter image description here

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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -