简体   繁体   English

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

[英]android forward declarations not working in 1.6

according to the official site, Android supports forward declarations from version 1.6 onwards. 根据官方网站,Android支持从版本1.6开始的前向声明。

Having adjusted the min SDK and target SDK requirements both to '4' in manifest.xml, the layout editor from eclipse is still complaining about unknown declarations in a relative layout: 在manifest.xml中将min 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'). 错误错误:找不到与给定名称匹配的资源(在'layout_above'中,值为'@id / ChkBoxSavePwd')。

  • ERROR Error: No resource found that matches the given name (at 'layout_alignLeft' with value '@id/EditTxtServer'). 错误错误:找不到与给定名称匹配的资源(在'layout_alignLeft'中,值为'@id / EditTxtServer')。

clean / rebuilding did not help.. anyone stumbled upon this matter ? 干净/重建没有帮助..任何人偶然发现这件事?

To use forward references, declare the reference (use the "@+id/..." notation) the first time you use the reference, not on the actual element. 要使用前向引用,请在第一次使用引用时声明引用(使用“@ + 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM