Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
6 replies Latest Post - ‏2012-11-22T06:18:34Z by IdanAdar
SystemAdmin
SystemAdmin
570 Posts
ACCEPTED ANSWER

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
    ACCEPTED ANSWER

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

    ‏2012-05-02T03:37:51Z  in response to SystemAdmin
    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
    ACCEPTED ANSWER

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

    ‏2012-05-02T04:01:21Z  in response to SystemAdmin
    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
    ACCEPTED ANSWER

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

    ‏2012-05-02T04:41:20Z  in response to SystemAdmin
    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
      ACCEPTED ANSWER

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

      ‏2012-11-22T06:11:49Z  in response to IdanAdar
      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?
  • SystemAdmin
    SystemAdmin
    570 Posts
    ACCEPTED ANSWER

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

    ‏2012-05-03T02:41:16Z  in response to SystemAdmin
    Thanks a lot Idan .It is working fine.
  • IdanAdar
    IdanAdar
    288 Posts
    ACCEPTED ANSWER

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

    ‏2012-11-22T06:18:34Z  in response to SystemAdmin
    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