[英]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 注意:我必须使用的库可以从这里下载: 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. 我目前在一个项目中,我们必须使用App Inventor Java Bridge库制作一个应用。 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.
我正在尝试将图像添加到按钮(App Inventor按钮,而不是Google小部件),但是似乎无法显示该图像。 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.
我将图像另存为.png文件,并将它们保存在drawable文件夹中。
The App Inventor Button sets the Image using this (eg.): App Inventor按钮使用以下方法设置图像:
myButton.Image("path of image");
But I can't find out what format .Image()
expects the file path to be in. 但是我找不到
.Image()
期望文件路径位于哪种格式。
I have no errors other than E/ButtonBase: Unable to load 'filepath'. 除了E / ButtonBase外,我没有其他错误:无法加载“文件路径”。 I have no problems setting the background color or the font size or any other methods associated with an App Inventor Button in Java.
我在设置背景颜色或字体大小或与Java中的App Inventor Button相关的任何其他方法时都没有问题。 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. 我尝试过:
"myimage.png"
, "R.drawable.myimage.png"
, "\\res\\drawable\\myimage.png"
等等。 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"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.