Topic
  • 6 replies
  • Latest Post - ‏2012-11-22T06:18:34Z by IdanAdar
SystemAdmin
SystemAdmin
570 Posts

Pinned topic [Solved] Not able to load the image in Option menu

‏2012-05-02T02:44:05Z |
I've created a new Options menu for Android. Below is the code that I used to create this

function wlEnvInit() 
{ WL.OptionsMenu.init(
{opacity: 
"0.5"
}); WL.OptionsMenu.addItem(
"first", sampleMethod, 
'Menu', 
{image: 
"images/icon1.png", enabled: 

true
}); wlCommonInit(); 
// Environment initialization code goes here 
}


Now I copied the png image to android/images folder as well as res/drawable/images folder of Android project. But when I open the Options menu, I get the following error
05-01 22:40:23.369: E/WLDroidGap(22336): Failed to find resource R.drawable.images/icon1.png

Can you please help me?
  • IdanAdar
    IdanAdar
    288 Posts

    Re: [Solved] Not able to load the image in Option menu

    ‏2012-05-02T03:37:51Z  
    The implementation varies between Worklight 4.2.1 and newer versions. I really need to know your Worklight Studio version in order to be able to help you.
  • SystemAdmin
    SystemAdmin
    570 Posts

    Re: [Solved] Not able to load the image in Option menu

    ‏2012-05-02T04:01:21Z  
    This is the version which we downloaded from Internet. Eclipse plugin version is 4.2.1.1189 and I think Worklight Server build version is 4.2.1.1183 (this is what I see in the start server logs)
  • IdanAdar
    IdanAdar
    288 Posts

    Re: [Solved] Not able to load the image in Option menu

    ‏2012-05-02T04:41:20Z  
    Okay, per Worklight 4.2.1's documentation of the Options Menu API for Android (pages 63-64), you need to use only the filename of the image.
    For example:
    
    WL.OptionsMenu.addItem(
    "first", function()
    {alert(
    "hello one")
    }, 
    'one', 
    {image: 
    'one', enabled: 
    
    true
    });
    


    Please see if the above is of help.
  • SystemAdmin
    SystemAdmin
    570 Posts

    Re: [Solved] Not able to load the image in Option menu

    ‏2012-05-03T02:41:16Z  
    Thanks a lot Idan .It is working fine.
  • SystemAdmin
    SystemAdmin
    570 Posts

    Re: [Solved] Not able to load the image in Option menu

    ‏2012-11-22T06:11:49Z  
    • IdanAdar
    • ‏2012-05-02T04:41:20Z
    Okay, per Worklight 4.2.1's documentation of the Options Menu API for Android (pages 63-64), you need to use only the filename of the image.
    For example: <pre class="jive-pre"> WL.OptionsMenu.addItem( "first", function() {alert( "hello one") }, 'one', {image: 'one', enabled: true }); </pre>

    Please see if the above is of help.
    Hi

    am using Worklight 5.0.1 and using the following code for getting options menu

    function wlEnvInit(){
    wlCommonInit();
    WL.OptionsMenu.init();
    WL.OptionMenu.addItem("first", function(){ alert("option1 selected"); },"first option",{
    image: "images/tabicon.png",
    enabled:true
    });
    alert("GetItem: "+WL.OptionsMenu.getItem("first"));
    WL.OptionsMenu.getItem("first").setEnabled(true);
    WL.OptionsMenu.setVisible(true);
    }

    But when I test it with android emulator it shows only Worklight Settings Option. Any idea how it can get working?
  • IdanAdar
    IdanAdar
    288 Posts

    Re: [Solved] Not able to load the image in Option menu

    ‏2012-11-22T06:18:34Z  
    This forum is for Worklight 4.2
    Please open a thread in the Worklight 5 development forum.

    Note: When using the OptionsMenu API, make sure to follow the documentation: http://public.dhe.ibm.com/ibmdl/export/pub/software/mobile-solutions/worklight/docs/wl_5_0_dev_ref.pdf
    You are not calling to the image in the appropriate way (see API in the documentation).

    Other than that see if there are any errors in LogCat.
    Paste them in the new thread you will open in the Worklight 5 development forum.

    Thanks,

    Idan Adar
    QA Engineer
    IBM Worklight Mobile Platform