Android: Does onCreate method run in tabView when we click on each tab?
In my project I have three tabs. I want to know, each time that I click a tab onCreate function runs or it runs just one time when it creates.
Actually, in one tab I want to show a开发者_运维知识库 picture. for the first time, default picture is shown. However, if user creates his picture (in other tabs), when he clicks this tab the new picture should be shown.
My problem is, only default picture is shown and it doesn't show new picture. I think onCreate method don't run each time that I click the tab. Am I right?
hi friend it depends up on whether the activity is still active or not, if the activity is in paused mode then only the onResume() method will be called, if the activity is destroyed then the onCreate() method will be called,
my suggestions is that if u want to write any code u can use onResume()
or else
u can explicitly kill previous activities using finish method of activity. to make sure that every time onCreate() method is invoked..
u can call this finish() in the tab class u have written for tabs before switching to other tabs
I had the same problem. Copied the same code in onResume() method & it worked as expected.
精彩评论