Question

I have this class: public class HeaderView extends RelativeLayout implements OnClickListener, ProgressBarListener

In every Activity, this HeaderView is shown as I put it in the XML layout. Now, the thing is that I want to be able to implement onResume in my HeaderView. When I launch an Activity, onCreate is called and the HeaderView draw the things I need at the top, but if I press back, my Activity will call onResume and my HeaderView is not going to be recreated and the old values will still be there. How can I implement onResume in my HeaderView or something similiar in order to recreate the HeaderView!?

Thanks in advance!

Was it helpful?

Solution

you cant call onResume in the HeaderView class as its is the callback method of the Activity class and the classes extending the Activity class.
So in the onResume of your Activity class, call a method of the HeaderView class something like refreshView(), and then your view can be refreshed.

Editted section:

You can make a BaseScreen class extending Activity and implement this thing in its onResume.
Now extend this class in all your activities instead of the Activity class.
This will make to run refreshView() every time onResume is called an you no longer need to define it in every activity class of your code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top