Closed IvoPereira closed 9 years ago
Hi @IvoPereira
Are you using Titanium 4.0.X ?
Maybe it's a bug. Your code looks good. I wonder if providing a density-independent image resource would solve this because the same thing is working in the example. I'd need to change how to resolve the image then. Could be worth a try.
Hello @manumaticx,
I'm using Titanium Studio v. 3.4.1.201410281727 and Titanium SDK 3.5.1.GA.
I'm testing on a 4.2.2 device.
That snippet is working in the example, however the example does not use MVC and its folder structure (controllers, models, views), and is only based in an app.js file at root. Possibly may be that related to the problem locating the files?
As soon as I get office I will try with some density-independent image resources, and I'll let you know the result.
Thanks.
There shouldn't be a difference when using Alloy because Alloy creates a classic project with the same folder structure.
I've just tested an fixed-density image and I do get the same error:
ActionbarextrasModule: (main) [2,3204] Couldn't resolve /images/icon_menu.png
I recommend you using res-mdpi
, res-hdpi
, res-xhdpi
, res-xxhdpi
resources for icons. This will solve your issue.
But I also will try to resolve resources within the /images/
directory.
Hey @manumaticx,
Thanks for the feedback. I was trying to follow your suggestion, so I've put the image inside all of the folders you mentioned, using the path: /PROJECT_NAME/app/assets/images/res-hdpi /PROJECT_NAME/app/assets/images/res-mdpi /PROJECT_NAME/app/assets/images/res-xhdpi /PROJECT_NAME/app/assets/images/res-xxhdpi
However, it seemed to change something in the location where it was looking for the file, but it was still not able to find it (and the files were moved to Resources folder as expected).
Hm, I'm not sure what's going on here!
I've just created a fresh new Alloy app with Titanium 3.5.1.GA and ABX 1.6.3 to test this. But I am not able to reproduce this error.
The resource path in your log is also very strange. It should actually log the path that was passed to setHomeAsUpIcon
, not the resolved path. I will have to do some more testing in order to fix this. Hopefully I can come up with a solution here.
If you find anything that could help me to find the reason for this, please let me know.
I'll be happy to assist you debugging the problem @manumaticx.
I've tried with a live device LG-G2 using Ti-Shadow (and without it - through TitaniumStudio directly).
The image I'm using is this one: http://i.imgur.com/AR7zIc8.png
Let me know if you need anything else.
@manumaticx strange but I get a similar error
[ERROR] ActionbarextrasModule: (main) [1441,2453] Couldn't resolve ic_menu_black_24dp.png
and the ic_menu_black_24dp.png is in app/assets/android. Also tried with a / prefix and still not found
@ndastur as stated in the above comment I'd recommend using res-mdpi
, res-hdpi
, res-xhdpi
, res-xxhdpi
- this probably solves the error
@manumaticx thanks. I have been looking into the code and I think it is because you are using the getResourceId helper function. Looking deeper into the Appc source this seems to be a deeper level function.
Looking at how Appc resolve the setIcon in their actionbar implementation https://github.com/appcelerator/titanium_mobile/blob/master/android/titanium/src/java/org/appcelerator/titanium/proxy/ActionBarProxy.java I think some higher level SDK helper function is required.
Specific bit of code that might help is
private Drawable getDrawableFromUrl(String url)
{
TiUrl imageUrl = new TiUrl((String) url);
TiFileHelper tfh = new TiFileHelper(TiApplication.getInstance());
return tfh.loadDrawable(imageUrl.resolve(), false);
}
@ndastur Thank you for this. Do you think there is a chance that you could build the module and test this?
Unable to setHomeAsUpIcon with titanium 4.0.X
Can any one help me out.
@ChanakyaSrinivas Hi there, I need some more info! This is not considered as a bug until you instruct me how to reproduce the issue.
Environments: Tiatanium sdk 4.1.0 MVC Alloy 1.6.2
code:
output:
Not getting any error related to setHomeAsUpIcon. But Icon is not visible left side corner.
@ChanakyaSrinivas try adding actionBar.displayHomeAsUp = true;
before the line where you set the icon
if (actionBar){
actionBar.displayHomeAsUp = true;
abx.setTitle("Example");
abx.setHomeAsUpIcon("/images/drawericon.png");
}
As per your suggestion changed my code. It's working fine.
Great. Nice to hear.
So I think I can close this issue here since setHomeAsUpIcon
works as expected and the behavior described in the original question is not reproducible.
Please feel free to reopen if you can provide test code to reproduce this issue.
Hi All,
Module is not working for Titanium SDK 5.3.1GA and Alloy 1.8.7
Environments: Npm Version = 2.11.3 Titanium CLI Version = 5.0.8 Titanium SDK Version = 5.3.1.GA Alloy Version = 1.8.7
Error:
[ERROR] : TiApplication: java.lang.ClassCastException: org.appcelerator.titanium.TiActivity cannot be cast to android.support.v7.app.ActionBarActivity [ERROR] : TiApplication: at com.alcoapps.actionbarextras.ActionbarextrasModule.getActionBar(ActionbarextrasModule.java:117) [ERROR] : TiApplication: at com.alcoapps.actionbarextras.ActionbarextrasModule.handleSetHomeAsUpIcon(ActionbarextrasModule.java:523) [ERROR] : TiApplication: at com.alcoapps.actionbarextras.ActionbarextrasModule.handleMessage(ActionbarextrasModule.java:175) [ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:98) [ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:148) [ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:5417) [ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Native Method) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
@ChanakyaSrinivas Try updating the Module
Hello,
I'm using Alloy MVC, and inside of one of my controllers, I'm using the following:
I do have an image in /PROJECT_NAME/app/assets/images/icon_menu.png, and my controller is located in /PROJECT_NAME/app/controllers/example.js.
Just to note that all the others images for example in Titanium ImageViews load fine, using the same schema.
When starting my application, the title do change to "Example", however the homeAsUpIcon does not change and an error is shown in console:
I've already tried to play with slashes and some folder derivations in icon location, but I am not being able to get it work. Is it possible this is a bug in the module?
Thanks