The meaning of @android



我想问一下android:id="@android:id/list中的@android是什么意思?我在不同的android样本和教程中看到过它,我也在谷歌上搜索过它。我发现的唯一解释是"列表和空id是由Android平台为我们提供的,所以,我们必须用Android作为id的前缀:"from http://developer.android.com/resources/tutorials/notepad/notepad-ex1.html

谢谢。

android:

包含平台中包含的应用程序使用的资源类,并定义应用程序对系统特性的权限。

你可以在你自己的应用程序中直接使用这些R类中的一些资源,但是为了提供一个没有外部依赖的内聚应用程序包,你通常应该只使用你直接在应用程序中提供的资源。特别是,你不应该从android包中使用可绘制的资源,因为它们可能会在平台版本之间发生变化,从而导致与你的设计不可预见的冲突。通常,样式是您应该直接从这些资源中使用的唯一资源。

所以你正在使用android的资源,如list, empty等。通过在XML文件中使用'@android:id'。

差@ + id和@android: id:

@+id/foo means you are creating an id named foo in the namespace of
your application. You can refer to it using @id/foo. @android:id/foo
means you are referring to an id defined in the android namespace.
This namespace is the namespace of the framework. In this case, you
need to use @android:id/list and @android:id/empty because these are
the id the framework expects to find (the framework knows only about
the ids in the android namespace.

谢谢。

相关内容

最新更新