Android call Method after rendering a Layout
Android call Method after rendering a Layout
I started programming Android apps. But I have one question. Is it possible to call a method first after the Layout belonging to the Activity has renderd and not at the onCreate() method?
3 Answers
3
Look at the activity lifecycle (scroll down a bit for it) to see the hooks that you have. The layout is usually rendered (as in measured, laid-out, etc) when you call setContentView
inside onCreate
, but becomes visible on-screen only after onResume
. Note that onResume
can be called multiple times, while onCreate
is only called once.
setContentView
onCreate
onResume
onResume
onCreate
no it is not possible to call a method first after the Layout belonging to the Activity has renderd. oncreate is start point of your activity. check following link for more information
http://developer.android.com/training/basics/activity-lifecycle/index.htmlenter link description here
Use onStart()
:
onStart()
@Override
protected void onStart() {
super.onStart();
// WRITE YOUR CODES HERE
}
You can write after rendering works inside the onStart()
for deep knowledge visit developer.android.com
onStart()
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.