Reputation: 14237
I want to develop an application that has 4 buttons top and 4 buttons bottom in all activities. The problem is that I don't want to define button's handlers in all activities (because it is simpler to make modifications in only 1 place).
One solution I thought was: Do a Main Menu that extends Activity then extend all activities from Main Menu. However, I want to use Lists that extend from ListActivity.
Is there a way to declare and define handlers only once and use those buttons in all activities?
Upvotes: 1
Views: 316
Reputation: 14237
Solved that issue implementing a singleton class.
Imagine that an application had 4 fixed buttons. You write 4 methods for those buttons in the singleton class and then call them from every Activity you write. Isn't the perfect solution, however it grants you a single space where you can change the handlers and spread those modifications automatically by all activities.
Hope it helps someone.
Upvotes: 0
Reputation: 44919
It's pretty easy to refactor a ListActivity
into an Activity
that has a ListView
. If you do this, you can follow your "Main Menu" plan.
Upvotes: 1