【发布时间】:2016-04-28 06:37:35
【问题描述】:
我正在学习 Gif 教程,并在我的 wear/java/com.example.marcus.prog 文件夹中创建了一个名为“GIFView”的自定义类,但我无法从我的 XML 布局中引用该类。我尝试了各种组合,但我不断收到两个关于找不到类的错误。
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.marcus.prog/com.example.marcus.prog.AttackScreen}: android.view.InflateException: Binary XML file line #20: Error inflating class com.example.marcus.prog.GIFView
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.marcus.prog.GIFView" on path: DexPathList[[zip file "/system/framework/com.google.android.wearable.jar", zip file "/data/app/com.example.marcus.prog-4/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
我的 XML 文件看起来像
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:deviceIds="wear"
android:orientation="vertical"
>
<prog.GIFView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
谢谢
【问题讨论】:
-
你在布局中引用的包和类名是什么
GIFView?