@Id和@android之间的区别:ID [英] difference between @id and @android:id

查看:138
本文介绍了@Id和@android之间的区别:ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?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>

什么是@android之间的区别:在这种情况下,ID和@id

what is the difference between @android:id and @id in this case?

推荐答案

您需要使用 @ + ID 当你要定义你自己的ID到一个视图,这在这种情况下是 section_spinner 。而 @android:ID 当你需要在架构设置视图的ID Android的pre-定义的ID被使用。对于例如,当使用ListActivity,TabWidget /的FrameLayout在TabHost等。

You need to use @+id when you are defining your own Id to a view, which in this case is section_spinner. And @android:id is used when you need to set an Id of a view to android's pre-defined Id in framework. for e.g when using ListActivity, TabWidget/FrameLayout in TabHost and etc.

这篇关于@Id和@android之间的区别:ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆