ricardoalcocer / actionbarextras

Titanium Android Native Module that exposes ActionBar features not exposed by the Titanium SDK
MIT License
148 stars 61 forks source link

Can I replace the arrow icon in actionbar with another image icon with this module? #93

Closed myselfdeveloping closed 9 years ago

myselfdeveloping commented 9 years ago

I'm trying to change the arrow icon in action bar with another icon but I don't found a solution! Someone can help me?

manumaticx commented 9 years ago

Yes, it's all in the docs / example

activity.onCreateOptionsMenu = function(e){
  activity.actionBar.displayHomeAsUp = true;
  abx.setHomeAsUpIcon("/images/myArrow.png");
};
myselfdeveloping commented 9 years ago

Doesn't work for me! This is my code:

$.index.addEventListener('open',function(e){

   var activity = $.index.getActivity();

   if (activity) { 

        var abx = require('com.alcoapps.actionbarextras');
        abx.title = "Valuta Amici";
        abx.titleColor = "White";
        abx.backgroundColor = "#017695";

     activity.onCreateOptionsMenu = function(e){
            activity.actionBar.displayHomeAsUp = true;
            abx.setHomeAsUpIcon("/images/icone/cerca.png");
    }; 

    }

});

The error that Console returns is: [ERROR] : ActionbarextrasModule: (main) [785,3842] Couldn't resolve /images/icone/cerca.png but the path is rigth. Where I'm wrong?

manumaticx commented 9 years ago

Try calling activity.invalidateOptionsMenu(); after defining onCreateOptionsMenu:

$.index.addEventListener('open',function(e){

   var activity = $.index.getActivity();

   if (activity) { 

        var abx = require('com.alcoapps.actionbarextras');
        abx.title = "Valuta Amici";
        abx.titleColor = "White";
        abx.backgroundColor = "#017695";

        activity.onCreateOptionsMenu = function(e){
            activity.actionBar.displayHomeAsUp = true;
            abx.setHomeAsUpIcon("/images/icone/cerca.png");
        };

        activity.invalidateOptionsMenu();

    }

});
manumaticx commented 9 years ago

Ooops, this was wrong! :see_no_evil:

If it says "Couldn't resolve /images/icone/cerca.png" then you have to provide density-independent graphics (mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi), see #68

For reference, check out the example

myselfdeveloping commented 9 years ago

Thanks a lot!

manumaticx commented 9 years ago

You're welcome :)