Why this line xmlns:android=“http://schemas.android.com/apk/res/android” must be the first in the la

来源:互联网 发布:js 上传图片 编辑:程序博客网 时间:2024/03/29 07:27

In XML, xmlns declares a Namespace. In fact, when you do:

<LinearLayout android:id></LinearLayout>

Instead of calling android:id, the xml will use http://schemas.android.com/apk/res/android:id to be unique. Generally this page doesn't exist (it's a URI, not a URL), but sometimes it is a URL that explains the used namespace.

The namespace has pretty much the same uses as the package name in a Java application.

Here is an explanation.

Uniform Resource Identifier (URI)

A Uniform Resource Identifier (URI) is a string of characters which identifies an Internet Resource.

The most common URI is the Uniform Resource Locator (URL) which identifies an Internet domain address. Another, not so common type of URI is the Universal Resource Name (URN).

In our examples we will only use URLs.

ATTRIBUTES:
xmlns:android
Defines the Android namespace. This attribute should always be set to "http://schemas.android.com/apk/res/android".

0 0
原创粉丝点击