gpt4 book ai didi

android 前向声明在 1.6 中不起作用

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:37:40 24 4
gpt4 key购买 nike

根据官方网站,Android 从 1.6 版本开始支持前向声明。

在 manifest.xml 中将最小 SDK 和目标 SDK 要求都调整为“4”后,来自 eclipse 的布局编辑器仍在提示相对布局中的未知声明:

<xml>

<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ChkBoxSaveuser"
android:text="@string/options_saveuser"
android:layout_above="@id/ChkBoxSavePwd"
android:layout_marginTop="20dp"
android:layout_alignLeft="@id/EditTxtServer"/>

<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/EditTxtServer"
android:maxLines="1"
android:minWidth="200dp"
android:layout_marginTop="10dp"
android:layout_gravity="center_horizontal"
android:layout_above="@id/ChkBoxSaveuser"/>

</xml>

Multiple annotations found at this line:

  • ERROR Error: No resource found that matches the given name (at 'layout_above' with value '@id/ ChkBoxSavePwd').

  • ERROR Error: No resource found that matches the given name (at 'layout_alignLeft' with value '@id/EditTxtServer').

清理/重建没有帮助..有人偶然发现了这件事吗?

最佳答案

要使用前向引用,请在第一次使用引用时声明引用(使用“@+id/...”符号),而不是在实际元素上。

<xml>

<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ChkBoxSaveuser"
android:text="@string/options_saveuser"
android:layout_above="@+id/ChkBoxSavePwd"
android:layout_marginTop="20dp"
android:layout_alignLeft="@+id/EditTxtServer"/>

<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@id/EditTxtServer"
android:maxLines="1"
android:minWidth="200dp"
android:layout_marginTop="10dp"
android:layout_gravity="center_horizontal"
android:layout_above="@id/ChkBoxSaveuser"/>

</xml>

关于android 前向声明在 1.6 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3836301/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com