android - save view instance of fragment in backstack -



android - save view instance of fragment in backstack -

i've read topic save instance state of fragment. think case different.

example: have fragment a, b. have edit text. type text edit text add together fragment b backstack.

then popbackstack fragment b => display.

but edittext empty.

here way fixed:

private class myfragment extends fragment { private view rootview = null; @override public view oncreateview(layoutinflater inflater, @nullable viewgroup container, @nullable bundle savedinstancestate) { if (rootview != null) { ((windowmanager) rootview.getparent()).removeview(rootview); } else { view v = inflater.inflate(r.layout.my_layout, container, false); // find view layout. rootview = v; } homecoming rootview; } }

it's auto maintain lastest state of fragment.

but here question:

does app spend much memory normal ? (because create new rootview save instance of view of fragment.) care how ondestroyview working in case ? if android scheme auto destroy view free memory -> why rootview variable still maintain instance ?

if android scheme don't kill rootview variable => create view medittextinput, mimageviewavatar.... reference "id" in layout => bad ?

(notes: rootview <=> variable save instance of root view of fragment.)

android performance android-fragments

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -