如何设置,在XML扩展视图类的路径? Android的工作室 [英] How to set a path for a class that extends View in xml? Android-Studio
问题描述
我发现下面的类<一href="https://android.googlesource.com/device/google/accessory/demokit/+/4de77996b19a3851675080072f029b0c7d0865ff/app/src/com/google/android/DemoKit/ColorWheel.java" rel="nofollow">https://android.googlesource.com/device/google/accessory/demokit/+/4de77996b19a3851675080072f029b0c7d0865ff/app/src/com/google/android/DemoKit/ColorWheel.java,但我真的不知道该怎么显示出来。我是很新的Android和我没有使用过这样的事情到现在。你能告诉我如何做一个活动该类显示器?
当我这样做
&LT; com.google.android.packageName.ColorWheel&GT;机器人:ID =@ + ID /视图机器人:layout_width =FILL_PARENT机器人:layout_height =WRAP_CONTENT&LT; /com.google.android.packageName.ColorWheel>
您需要使用自定义视图的完全限定路径布局的XML。
所以这样的:
<$p$p><$c$c><com.google.android.DemoKit.ColorWheel></com.google.android.DemoKit.ColorWheel>代替
只是这样的:
&LT; ColorWheel&GT;&LT; / ColorWheel&GT;
请注意,你需要修改包以匹配您的项目,即类存在 com.google.android.DemoKit
将需要改变无论包
此查看
的子类存在于
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 ?
When I do this
<com.google.android.packageName.ColorWheel> android:id="@+id/view" android:layout_width="fill_parent" android:layout_height="wrap_content" </com.google.android.packageName.ColorWheel>
You'll need to use the fully qualified path of the custom view in your layout xml.
So this:
<com.google.android.DemoKit.ColorWheel></com.google.android.DemoKit.ColorWheel>
instead of just this:
<ColorWheel></ColorWheel>
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扩展视图类的路径? Android的工作室的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!