Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Are icons supported for Android OptionMenu.MenuItem?

Note: reposting to correct title

Hi all,

I am having trouble setting an icon on an Android option menu, using the example code at the bottom of (https://developer.appcelerator.com/apidoc/mobile/1.3/Titanium.UI.Android.OptionMenu-module). Everything else works but the icon does not show.

I have even tried putting the image file in the same directory as the js file, but still with no success.

For example, icon : 'item1.png'

Note that I only have access to an emulator at this time.

I hope someone can kindly offer some suggestions.

Thanks

Hal

— asked May 21st 2010 by Paul Dowsett
  • android
0 Comments

3 Answers

  • Accepted Answer

    The path should be window relative. You can always reference it with an absolute path. (e.g /images/item1.png'). If you turn on your Trace level logging it may provide helpful information on the error.

    — answered May 21st 2010 by Don Thorp
    permalink
    1 Comment
    • I can confirm that icons for optionMenu menu items is working. A working exmaple would be:

      atl = Titanium.UI.Android.OptionMenu.createMenuItem({title : 'ATL', icon:'/images/camera.png'});
      

      …where "images" is a directory in the Resources folder.

      — commented November 4th 2010 by Paul Dowsett
  • Hi Don
    Thank you for your reply.
    If I use a path like '/images/item1.png', the title stops working.
    There is also nowhere in the kitchensink that uses an icon for OptionMenu.
    Have you had this working before?
    Thank you kindly
    Hal

    — answered May 21st 2010 by Paul Dowsett
    permalink
    0 Comments
  • Hi all,

    I am using icons in my Android applications and they work.

    What I did is copy the icons' images in the Resources folder, then I use the following code:

    var btn_add = Titanium.UI.Android.OptionMenu.createMenuItem({
        title: 'Add New Task',
        icon: 'add.png'
    });
    

    The code above is saved in a file but is not in the Root of the Resources folder, so if your .js file is in a sub-folder the code above should still work.

    — answered May 22nd 2010 by Simon Facciol
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.