in my Activity subclass OnCreate method i use setContentView(XXX) to setup the window layout. In certain circumstances it is necessary, at 'OnStart' time, for this Activity to be stopped. Calling in the OnStart the Activity.finish() method, actually stop the execution but cause a ugly flicker effect where my layout is shown for an instant before application dies.
Question is: is there an opposite of setContentView? Can I use an ipotetic clearContentView to empty the layout and avoid the flickering?
Thanks in advance L.
SetContentView is used to fill the window with the UI provided from layout file incase of setContentView(R. layout. somae_file). Here layoutfile is inflated to view and added to the Activity context(Window).
So, with respect to time, setContentView alone is faster, since it doesn't start a new activity. Hence, your app will show the new screen faster... On the other hand, if you call startActivity, this activity is put on the stack, so you can go back by pressing the back button.
As onCreate() of an Activity is called only once, this is the point where most initialization should go: calling setContentView(int) to inflate the activity's UI, using findViewById to programmatically interact with widgets in the UI, calling managedQuery(android.
You can make a clean xml clear.xml
with no content and
setContentView(clear);
You can try, but i'm not sure it'll help .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With