gpt4 book ai didi

android - 在 Android 中使用 Gama 组件

转载 作者:行者123 更新时间:2023-11-29 15:27:02 25 4
gpt4 key购买 nike

我想在 Android 中使用 Gama 组件来使我们的应用程序变得更好。我已经下载了 Gama 的 jar,即使它抛出错误。我已经点击了以下链接 http://developer.digitalaria.com/devguide/gama/en/gama/tile_android.php .

Java

import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import com.digitalaria.gama.tile.Tile;

public class GamaAndroidActivity extends Activity {
Button button;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}

}

XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<com.digitalaria.gama.tile.Tile
android:id="@+id/tile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />

错误

    07-02 16:52:02.623: E/AndroidRuntime(1849): FATAL EXCEPTION: main
07-02 16:52:02.623: E/AndroidRuntime(1849): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.gama/com.test.gama.GamaAndroidActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class com.digitalaria.gama.tile.Tile
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.os.Handler.dispatchMessage(Handler.java:99)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.os.Looper.loop(Looper.java:123)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-02 16:52:02.623: E/AndroidRuntime(1849): at java.lang.reflect.Method.invokeNative(Native Method)
07-02 16:52:02.623: E/AndroidRuntime(1849): at java.lang.reflect.Method.invoke(Method.java:521)
07-02 16:52:02.623: E/AndroidRuntime(1849): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-02 16:52:02.623: E/AndroidRuntime(1849): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-02 16:52:02.623: E/AndroidRuntime(1849): at dalvik.system.NativeStart.main(Native Method)
07-02 16:52:02.623: E/AndroidRuntime(1849): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class com.digitalaria.gama.tile.Tile
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
07-02 16:52:02.623: E/AndroidRuntime(1849): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.app.Activity.setContentView(Activity.java:1647)
07-02 16:52:02.623: E/AndroidRuntime(1849): at com.test.gama.GamaAndroidActivity.onCreate(GamaAndroidActivity.java:15)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
07-02 16:52:02.623: E/AndroidRuntime(1849): ... 11 more
07-02 16:52:02.623: E/AndroidRuntime(1849): Caused by: java.lang.ClassNotFoundException: com.digitalaria.gama.tile.Tile in loader dalvik.system.PathClassLoader[/data/app/com.test.gama-1.apk]
07-02 16:52:02.623: E/AndroidRuntime(1849): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
07-02 16:52:02.623: E/AndroidRuntime(1849): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
07-02 16:52:02.623: E/AndroidRuntime(1849): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
07-02 16:52:02.623: E/AndroidRuntime(1849): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
07-02 16:52:02.623: E/AndroidRuntime(1849): ... 20 more

最佳答案

错误说

android.view.InflateException: Binary XML file line #7: Error inflating class com.digitalaria.gama.tile.Tile

这意味着您在声明的 xml 文件中的第 7 行有错误com.digitalaria.gama.tile.Tile 所以检查该类是否可用。

在您使用 xml 文件的类(class)中:

 import com.digitalaria.gama.tile.Tile;

编辑:

要添加 Gama 库,请将其从 javaBuildpath 中移除并改为执行以下操作:

 1. Create a new folder, libs, in your Eclipse/Android project.
2. Right-click libs and choose Import -> General -> File System, then
Next, Browse in the filesystem to find the library's parent
directory and add your GAMA jar.
3. Right-click on your project, choose Build Path -> Configure Build
Path, then click the Libraries tab, then Add JARs..., navigate to
your new JAR in the libs directory and add it.
4. Clean the project

关于android - 在 Android 中使用 Gama 组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11292679/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com