How to handle Actionbar’s options?

Asked

Viewed 59 times

1

Hello, in the app I am doing all my activities (except 2) has the extends of another Activity (BaseActivity) where I treat the options available on ActionBar, with this I avoid repeating the code in all activities. It happens that in those 2 activities where I do not have that extends I have a listview that is made through an Adapter (so I have to do extends BaseAdapter implements ListAdapter ).

My question is, how am I going to deal with the options available in Actionbar for these 2 activities since I cannot do extends of BaseActivity? Do I have to repeat the code? Like they usually do?

Example: All activities are like this:

public class MainActivity extends BaseActivity {....}

except 2, which are so:

public class MyAdapter extends BaseAdapter implements ListAdapter {...}

How do I handle these two? Thank you!

  • Adapter has nothing to do with Activity, what you must be asking is about ListActivity. Correct?

  • Possible duplicate of http://answall.com/questions/38337/addir-bot%C3%B5es-na-action-bar-quando-usa-listactivity

  • @Piovezan with this "Adapter has nothing to do with Activity" you solved my problem. I was getting confused...the Activity "calls" an Adapter to fill Listview. I was thinking that the Adapter was an activity : Thank you!!

  • Glad it worked out. I thought it was the problem of extending activities ListActivity, which in fact prevents the extends BaseActivity or extends ActionBarActivity. The solution in this case would be to implement the ListActivity manually in Activity, as indicated in the link I passed. Here is the comment for those who find this question going through the second problem.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.