之间是什么@ + ID / Android的区别:列表,并@ + ID /名单 [英] What is difference between @+id/android:list and @+id/list

查看:192
本文介绍了之间是什么@ + ID / Android的区别:列表,并@ + ID /名单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道什么是之间的的区别@ + ID / Android的:清单 @ + ID /列表。我知道最后一个是常规的ID分配,但第一个看起来不一样。是什么使得它特别的?

I am wondering what's the difference between @+id/android:list and @+id/list. I know the last one which is a regular id assignment but the first looks different. What makes it special?

我在那里看到了它: 我在学习上的ListView,ListAdapter之类的东西,作者定义的ListView中,如下所示布局的xml文件:

Where I saw it: I was studying on ListView, ListAdapter and things like that and the author define the ListView in layout xml file as below :

<?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="@+id/android:list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    />
<TextView
    android:id="@+id/android:empty"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:text="@string/main_no_items"/>
</LinearLayout>

和还让我提 @ + ID / Android的:空 ID以及

他还延伸 ListActivity 类。

下面是文章的源。

Here is the source of the article.

并且还什么在我的脑海里的问题是:

  1. 我们是否应该延长 ListActivity ?也许我想的活动还包含其他意见。
  2. 我们用 @ + ID / Android的:清单只是因为我们扩展 ListActivity 或者我们可以使用相同的约定如果我们延长活动
  1. Should we extend ListActivity? Maybe I want an Activity which also contains other Views.
  2. We use @+id/android:list just because we extend ListActivity or we can use the same convention if we extend Activity?

感谢。

推荐答案

在Android的资源ID是具体到一个包(这是很好的,否则你就会有很多的冲突,如果你的应用程序是处理几个包在同一时间)。

Resource IDs in Android are specific to a package (which is good, or else you'd have lots of conflicts if your app is dealing with several packages at the same time).

@ + ID /列表将创建一个在你的应用程序中的资源ID(=你的包)一个名为清单,并给它一个唯一的ID。在code,这将是 R.id.list

@+id/list will create a resource ID in your app (=your package) with the name "list" and give it a unique ID. In code, that would be R.id.list.

@android:ID /列表将使用ID列表从包装机器人(其中,在code,将 android.R.id.list

@android:id/list will use the ID "list" from the package android (which, in code, would be android.R.id.list.

编辑:需要补充更正Hedlund的大卫指出:正确的引用是 @android:ID /列表。此外, + 表示你定义一个新的ID - 你显然不需要,当你引用了Android API中定义的东西

Need to add the corrections David Hedlund pointed out: The proper reference would be @android:id/list. Also, + indicates you're defining a new ID - you obviously don't need that when you're referencing something that was defined in the Android API.

这篇关于之间是什么@ + ID / Android的区别:列表,并@ + ID /名单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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