【问题标题】:how to connect View class with xml in eclipse android如何在eclipse android中将View类与xml连接
【发布时间】:2013-11-04 15:01:34
【问题描述】:

我有我的 gamefield.xml,我只想在画布上用 onDraw() 绘制一个在 gamefield.xml t 操作的矩形...我一直在寻找答案,但没有任何效果...

我可以为此做些什么,。谢谢。

这是我的gamefield.xml,但我认为它没有用。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

<View class= "cruz.jayson.bantumi.Board"
    android:id="@+id/myBoard"
    android:layout_width="fill_parent"
    android:layout_height="match_parent" 
    />

</LinearLayout>

【问题讨论】:

标签: java android xml eclipse


【解决方案1】:

根据Creating a Custom View Class documentation,您的 XML 应如下所示:

<cruz.jayson.bantumi.Board
    android:id="@+id/myBoard"
    android:layout_width="fill_parent"
    android:layout_height="match_parent" />

您在元素名称中指定 View 类,而不是在 class 属性中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-05
    • 1970-01-01
    • 1970-01-01
    • 2018-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多