简体   繁体   English

如何使用Android Studio的App Inventor Java Bridge库指定图像路径?

[英]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.

相关问题 你如何使用android studio在本地存储应用程序数据? - How do you store app data locally using android studio? 如何在Java Android Studio项目中使用.so共享库 - How Do You Use .so Shared Library in Java Android Studio Project 如何在 Java 库中指定资源路径? - How to specify resourses path in a Java library? 如何将原生库(.so)添加到android studio? - How do you add a native library (.so) to android studio? 如何为使用sbt本机打包程序构建的应用程序指定java.library.path? - How can I specify java.library.path for an app built with sbt native packager? 在Android Studio中使用Java库 - Using a java library in Android Studio 如何在Gradle Java-library Project构建脚本中指定buildConfigField - How do you specify buildConfigField in Gradle Java-library Project build script 你如何在 Java 中指定字节文字? - How do you specify a byte literal in Java? 如何使用在Android Studio中创建的应用程序将文件上传到Google云端存储? - How do you upload a file using an app created in Android Studio to Google Cloud Storage? 在Android Studio中,如何使用Java代码将片段切换到另一个片段 - In Android Studio, how do you switch a fragment to another fragment using java code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM