android - Is it ok to use setContentView() once in OnResume() -


i have heard things how bad use setcontentview()

pattern "one activity, multiple views": advantages , disadvantages

however wondering, unlikely application cause memory leaks, if use setcontentview() once in onresume() method of activity?

whenever user opens app, checks see if has been enabled in settings. if has been enabled app uses different screen compared original screen.

therefor code looks this:

 @override     protected void onresume() {        super.onresume();        inputmethodmanager im = (inputmethodmanager)getsystemservice(input_method_service);        string list = im.getenabledinputmethodlist().tostring();        if(stuff true){         setcontentview(r.layout.activityscreen_enabled);        }    }  } 

would using setcontentview() unlikely cause memory leaks , other such problems? or there better solution?

i'm doing android since few years , have never done because stick pattern having setcontentview in oncreate.

however, not believe have big troubles doing (for memory leaks mean).

nevertheless, not see point of doing such thing, pattern of activity (or how understood it) more:

i create view in oncreate , update data in onresume , if data add/remove view , if data b add/remove other view.

to complete, read (really good) link , think maybe misunderstood how can apply commonsware saying: can have multiply views without having different setcontentview: view structure needs, in case, modular , able load subviews dynamically (or, @ least, it's how colleague , doing ;) ).

for example, have empty layout base of activity (let's blue background) , every view want have (every case), have dynamic layout load @ point in life cycle (probably @ onresume). not believe you're doing particularly bad doubt thought ^^

this link agrees me


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -