简体   繁体   中英

How do you specify image path using App Inventor Java Bridge library for Android Studio?

Note: The library I have to use can be downloaded from here: http://www.appinventor.org/jBridgeIntro

I'm currently working on a project in which we have to make an app using the App Inventor Java Bridge Library. I'm trying to add an image to a button (App Inventor Button, not google widget) but I can't seem to get the image to display. I've tried multiple formats for image-paths but nothing seems to work. I have the images saved as .png files and I have them in the drawable folder.

The App Inventor Button sets the Image using this (eg.):

myButton.Image("path of image");

But I can't find out what format .Image() expects the file path to be in.

I have no errors other than E/ButtonBase: Unable to load 'filepath'. I have no problems setting the background color or the font size or any other methods associated with an App Inventor Button in Java. It's just Image file paths that seem to be holding the project up.

I've tried: "myimage.png" , "R.drawable.myimage.png" , "\\res\\drawable\\myimage.png" and so on. Nothing seems to work.

This problem seems to happen with Image referencing in general in this library, whether it's a button/canvas/arrangement etc.

Does anybody have any ideas on what format it actually needs to be in?

(Note: If anyone has any code sample from this Library, related or unrelated to this question. It could help me better understand the library and solve this issue.)

原来我要做的就是在src/main创建一个“ assets”文件夹来存储应用程序所需的任何资产,并且一旦这样做,我就可以使用"myImage.png"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM