android转发声明在1.6中不起作用

android转发声明在1.6中不起作用,android,eclipse,android-relativelayout,forward-declaration,android-sdk-1.6,Android,Eclipse,Android Relativelayout,Forward Declaration,Android Sdk 1.6,根据官方网站,Android支持从1.6版开始的转发声明 在manifest.xml中将min-SDK和target-SDK要求都调整为“4”之后,eclipse的布局编辑器仍在抱怨相对布局中的未知声明: <xml> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/ChkBoxSaveuser" andro

根据官方网站,Android支持从1.6版开始的转发声明

在manifest.xml中将min-SDK和target-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>

在此行找到多个批注:

  • 错误:未找到与给定名称匹配的资源(位于“layout_above”处,值为“@id/ ChkBoxSavePwd')

  • 错误:找不到与给定名称(在“layout\u alignLeft”处)匹配的资源 “@id/edittxserver”)


清理/重建没有帮助。。有人偶然发现了这个问题吗?

要使用前向引用,请在第一次使用引用时声明引用(使用“@+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>