如何为在xml中扩展View的类设置路径?安卓工作室 [英] How to set a path for a class that extends View in xml? Android-Studio
问题描述
我发现了以下类 https://android.googlesource.com/device/google/accessory/demokit/+/4de77996b19a3851675080072f029b0c7d0865ff/app/src/com/google/android/DemoKit/ColorWheel.java,但是我真的不知道如何显示它.我对android很陌生,直到现在我还没有使用过这样的东西.您能告诉我如何在活动中显示该类吗?
I found the following class https://android.googlesource.com/device/google/accessory/demokit/+/4de77996b19a3851675080072f029b0c7d0865ff/app/src/com/google/android/DemoKit/ColorWheel.java, but I don't really know how to display it. I am quite new to android and I haven't used something like this until now. Could you tell me how to make that class display in an activity ?
当我这样做时
<com.google.android.packageName.ColorWheel> android:id="@+id/view" android:layout_width="fill_parent" android:layout_height="wrap_content" </com.google.android.packageName.ColorWheel>
推荐答案
您需要在布局 xml 中使用自定义视图的完全限定路径.
You'll need to use the fully qualified path of the custom view in your layout xml.
所以:
<com.google.android.DemoKit.ColorWheel></com.google.android.DemoKit.ColorWheel>
而不仅仅是这个:
<ColorWheel></ColorWheel>
请注意,您需要修改包以匹配项目中存在的类,即com.google.android.DemoKit
将需要更改为任何package
这个 View
子类存在于.
Note that you'll need to modify the package to match where the class exists in your project, i.e. com.google.android.DemoKit
will need to be changed to whatever package
this View
subclass exists in.
这篇关于如何为在xml中扩展View的类设置路径?安卓工作室的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!