Closed krem06 closed 8 years ago
Try using this sizes for the density independent images:
res-mdpi: 48 x 48
res-hdpi: 72 x 72
res-xhdpi: 96 x 96
res-xxhdpi: 144 x 144
res-xxxhdpi: 192 x 192
It must not be squares but I think the height matters (Should be 48dp).
abx.setActionbarImage({ image: '/images/test.png' });
will load the images from the /assets/android/images/res-*dpi
directories.
That error should be catched. So I'll leave this open as a bug.
No luck with the fix but now I'm getting the following error:
[INFO] : ActionbarextrasModule: (main) [267,2101] The image reference is a String object. [ERROR] : AndroidRuntime: FATAL EXCEPTION: main [ERROR] : AndroidRuntime: Process: com.rom.pascalcoste, PID: 27254 [ERROR] : AndroidRuntime: java.lang.NullPointerException: Attempt to invoke interface method 'int java.lang.CharSequence.length()' on a null object reference [ERROR] : AndroidRuntime: at android.text.SpannableStringBuilder.
(SpannableStringBuilder.java:48) [ERROR] : AndroidRuntime: at com.alcoapps.actionbarextras.ActionbarextrasModule.handleSetTitleFont(ActionbarextrasModule.java:410) [ERROR] : AndroidRuntime: at com.alcoapps.actionbarextras.ActionbarextrasModule.handleMessage(ActionbarextrasModule.java:179) [ERROR] : AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:98) [ERROR] : AndroidRuntime: at android.os.Looper.loop(Looper.java:135) [ERROR] : AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5539) [ERROR] : AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) [ERROR] : AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372) [ERROR] : AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960) [ERROR] : AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
On the appcelerator actionbar page there is a comment about latest sdk and how they deal with the icon in action bar:
In modern Android UIs developers should lean more on a visually distinct color scheme for toolbars than on their application icon. The use of application icon plus title as a standard layout is discouraged on API 21 devices and newer.
Could it be the reason ?
Are you trying to set the title with abx.setTitle()
?
From the log it seems that this is failing as there is no title since setActionbarImage()
explicitly removes the title.
If I add the setTitle() function then the app exit with no error...
After a long 4h fight I got it ! I had some errors in my syntax but also didn't properly use the module as I tried to add it in a tabgroup... But in the end I found the right syntax for my case:
$.tabGroup.open();
$.tabGroup.addEventListener("open", function() {
if (Ti.Platform.osname === "android") {
if (!$.tabGroup.activity) {
Ti.API.error("Can't access action bar on a lightweight window.");
} else {
var abx = require('com.alcoapps.actionbarextras');
abx.window = $.tabGroup;
actionBar = $.tabGroup.activity.actionBar;
if (actionBar) {
actionBar.displayHomeAsUp = true;
abx.setTitle("Example");
abx.setHomeAsUpIcon('/images/logo.png');
}
}
}
});
Thank you for the help ;)
Hi there,
I am trying to use your module in my alloy project and so far it works great ! The only thing is that when I try to change the Icon, the app just exit without any specific error: abx.setActionbarImage({ image: 'test.png' });