Java @android:eclipse无法识别id

Java @android:eclipse无法识别id,java,android,eclipse,Java,Android,Eclipse,在我的xml文件中,我有下面的列表视图 <ListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/editText1" android:layout_centerHorizontal="true" andro

在我的xml文件中,我有下面的列表视图

<ListView
    android:id="@android:id/list"        
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/editText1"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="14dp"
    android:divider="@color/blue"
    android:dividerHeight="2dip"
    android:background="@drawable/list_divider"
    >
</ListView>
“列表无法解析或不是字段”这句话有一个错误。但是如果我将id更改为
android:id=“@+id/list”

我如何通过这种方式使用id访问视图
android:id=“@android:id/list”


另外,两种定义ID的方法的基本区别是什么。请提前感谢假设您的
活动扩展了ListActivity
,您可以使用方便的方法访问它

ListView myListView = getListView();
否则,您将使用android.R.id.list访问它

还有,定义ID的两种方法的基本区别是什么

  • @android:id
    引用了内置的android
    资源
  • @+id
    是一个用户定义的id,它将添加到
    R.java
    文件中,稍后使用
    @id

  • 你必须提到你的身份证

    android:id=“@+id/list”

    @+id/list将在你的应用程序(=你的包)中创建一个名为“list”的资源id,并给它一个唯一的id。在代码中,这将是R.id.list

    @android:id/list将使用android包中的id“list”(在代码中是android.R.id.list.

    • Android资源id由xml中的
      @Android:id/list
      引用 Java代码中的android.R.id.list

    • 用户定义的id由xml中的
      @+id/list
      引用,并且 Java代码中的
      R.id.list
      +
      表示资源id值将在编译时生成

    • id在资源文件中定义为
      将 在xml中被引用为
      @id/list
      ,在Java中被引用为
      R.id.list
      代码


    @+id
    用于定义新的
    id
    @android:id
    用于引用
    id
    。这样做:
    ListView myListView=(ListView)findViewById(android.R.id.list);
    ADT不再受支持,人们最终应该切换到android Studio。。。
    ListView myListView = getListView();