android:id="@id/android:list"在布局文件里为什么要写这句话
这是在是要引用id文件里的什么东西吗?但我在文件里找不到一个叫id的文件啊请大家教教我

解决方案 »

  1.   

    这个是注册ListView的id,跟一般注册id的方法不一样的~
      

  2.   

    这个id在源码frameworks\base\core\res\res\layout\activity_list.xml中
    内容如下:<?xml version="1.0" encoding="utf-8"?>
    <!-- Copyright (C) 2009 The Android Open Source Project     Licensed under the Apache License, Version 2.0 (the "License");
         you may not use this file except in compliance with the License.
         You may obtain a copy of the License at
      
              http://www.apache.org/licenses/LICENSE-2.0
      
         Unless required by applicable law or agreed to in writing, software
         distributed under the License is distributed on an "AS IS" BASIS,
         WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         See the License for the specific language governing permissions and
         limitations under the License.
    --><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >    <ListView
            android:id="@android:id/list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            />    <TextView
            android:id="@android:id/empty"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:text="@string/activity_list_empty"
            android:visibility="gone"
            android:textAppearance="?android:attr/textAppearanceMedium"
            /></FrameLayout>
      

  3.   

    你引用的id是系统的id哦。2楼给出源码了。
      

  4.   

    android:id="@id/android:list"是对于ListView子类使用的
    一般的Activity中添加ListView控件是可以自己设置id的