Search code examples
imagerubymotion

Accessing images in .rb file using RubyMotion Android


I am trying to access images from resources folder by using Android::R::Drawable::. It is showing "false" value.How can I get image id in .rb file, but in .xml file it is working.

All suggestions are acceptable

Thanks in advance.


Solution

  • After Struggling a lot i found an answer.

    In java after compilation .R file will generate in that all id's of resources file will be there but in RubyMotion no .R file will get create. So, you have to use below snippet.

    Suppose you have "ecollect.png" in drawable folder.If you want to access in .rb file you have to use below code.

    resources.getIdentifier("ecollect", "drawable", self.getPackageName)

    Enjoy :)