【问题标题】:Documentation Clarification for Android Layout ID parameter needed需要 Android Layout ID 参数的文档说明
【发布时间】:2014-04-17 16:24:03
【问题描述】:

我对以下链接中的 android 文档有疑问。

http://developer.android.com/guide/topics/ui/accessibility/apps.html

为什么 nextFocusDown 有“+” id (android:nextFocusDown=”@+id/text”)?nextFocusUp="@id/edit" 没有“+” id ?不应该都没有“+”

<LinearLayout android:orientation="horizontal"
        ... >
    <EditText android:id="@+id/edit"
        android:nextFocusDown=”@+id/text”
        ... />
    <TextView android:id="@+id/text"
        android:focusable=”true”
        android:text="Hello, I am a focusable TextView"
        android:nextFocusUp=”@id/edit”
        ... />
</LinearLayout>

我指的是android文档的这一部分。

http://developer.android.com/guide/topics/ui/declaring-layout.html#attributes

加号 (+) 表示这是一个新的资源名称,必须 被创建并添加到我们的资源中(在 R.java 文件中)。

【问题讨论】:

    标签: android android-layout android-activity android-resources android-drawable


    【解决方案1】:

    您正在使用 android:id 的 XML 属性,然后您正在指定一个新 id 以在 R.java 中创建一个新条目,这就是您必须包含 (+) 符号的原因。

    但是在这里:

    android:nextFocusUp="@id/edit"
    

    您指的是上面已经创建的 id。

    【讨论】:

    • 你说得对,我知道,为什么 nextFocusDown 有 + 号?
    • 这可能是因为@+id/text 尚未创建。如果不允许,请尝试删除“+”这是原因。
    猜你喜欢
    • 2012-08-28
    • 1970-01-01
    • 2014-01-20
    • 1970-01-01
    • 1970-01-01
    • 2013-08-22
    • 2014-10-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多