den*_*iss 14 android android-layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="@android:id/list" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_weight="1" />
<Spinner android:id="@+id/section_spinner"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_margin="5dp" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
@android:id和@id在这种情况下有什么区别?
小智 24
字符串开头的at符号(@)表示XML解析器应解析并扩展ID字符串的其余部分,并将其标识为ID资源.加号(+)表示这是一个新的资源名称,必须创建并添加到我们的资源中(在R.java文件中).Android框架提供了许多其他ID资源.引用Android资源ID时,您不需要加号,但必须添加android包命名空间.
@+id/section_spinner表示您正在应用程序的命名空间中创建名为section_spinner的id.您可以使用@ id/section_spinner来引用它.
@android:id/list 意味着你指的是android命名空间中定义的列表.
如果符号尚不存在,则"+"表示创建符号.在引用android:symbols时你不需要它(并且不应该使用它),因为这些已经由平台为你定义了,你无论如何都不能在那个命名空间中创建自己的.
waq*_*lam 23
您需要在@+id将自己的Id定义到视图时使用,在本例中为section_spinner.并且@android:id当您需要在框架中将视图的Id设置为android的预定义Id时使用.例如,当在TabHost中使用ListActivity,TabWidget/FrameLayout等时
id你自己的id,Android id是android平台中的默认id res/values/ids.xml有一些ID如下所示API 10
res/values/ids.xml
Run Code Online (Sandbox Code Playgroud)
这些都是来自android的默认ID
<resources>
<item type="id" name="background" />
<item type="id" name="checkbox" />
<item type="id" name="content" />
<item type="id" name="empty" />
<item type="id" name="hint" />
<item type="id" name="icon" />
<item type="id" name="icon1" />
<item type="id" name="icon2" />
<item type="id" name="input" />
<item type="id" name="left_icon" />
<item type="id" name="list" />
<item type="id" name="menu" />
<item type="id" name="message" />
<item type="id" name="primary" />
<item type="id" name="progress" />
<item type="id" name="right_icon" />
<item type="id" name="summary" />
<item type="id" name="selectedIcon" />
<item type="id" name="tabcontent" />
<item type="id" name="tabhost" />
<item type="id" name="tabs" />
<item type="id" name="text1" />
<item type="id" name="text2" />
<item type="id" name="title" />
<item type="id" name="title_container" />
<item type="id" name="toggle" />
<item type="id" name="secondaryProgress" />
<item type="id" name="lock_screen" />
<item type="id" name="edit" />
<item type="id" name="widget_frame" />
<item type="id" name="button1" />
<item type="id" name="button2" />
<item type="id" name="button3" />
<item type="id" name="extractArea" />
<item type="id" name="candidatesArea" />
<item type="id" name="inputArea" />
<item type="id" name="inputExtractEditText" />
<item type="id" name="selectAll" />
<item type="id" name="cut" />
<item type="id" name="copy" />
<item type="id" name="paste" />
<item type="id" name="copyUrl" />
<item type="id" name="switchInputMethod" />
<item type="id" name="keyboardView" />
<item type="id" name="closeButton" />
<item type="id" name="startSelectingText" />
<item type="id" name="stopSelectingText" />
<item type="id" name="addToDictionary" />
<item type="id" name="accountPreferences" />
<item type="id" name="smallIcon" />
<item type="id" name="custom" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12360 次 |
| 最近记录: |