Question

I've imported a project containing ActionBarSherlock Library. Here is a method defined in the code below for setting ActionBar.

boolean isAddedToFav=false;
@Override
 public void setActionBar(ActionBar actBar) {
super.setActionBar(actBar);

_actionBar.removeAllActions();
_actionBar.addAction(new Action() {

    @Override
    public void performAction(View view) {
        // TODO Auto-generated method stub

    }

    @Override
    public int getDrawable() {
        // TODO Auto-generated method stub
        if(!isAddedToFav)
            return R.drawable.bookmark2;
        else
            return R.drawable.bookmark;
    }
});}

Now I am confused about how this method gets called.Here getDrawable() sets an image icon to Action Button on ActionBar.Now I want to change this icon image when users clicks on this ActionButton.But I don't know how can i manually called the getDrawable(). So please someone explain me about this.

Was it helpful?

Solution

You can make a simple call this method where you want n change the Image according to your need in getDrawable()method

e.g setActionBar(Your actionbar object)

Hope this help to you!

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