When we develop layouts in Android all the xml files begin with
xmlns:android="http://schemas.android.com/apk/res/android"
What does this do and why for developing application my xmlns refers to a link in the web ?
PS : This is a newbie question
When we develop layouts in Android all the xml files begin with
xmlns:android="http://schemas.android.com/apk/res/android"
What does this do and why for developing application my xmlns refers to a link in the web ?
PS : This is a newbie question
xmlns is xml name space
The namespace is defined by the xmlns attribute in the start tag of an element. The namespace declaration has the following syntax. xmlns:prefix="URI".
xmlns:android
Defines the Android namespace. This attribute should always be set to "http://schemas.android.com/apk/res/android".
http://www.w3schools.com/xml/xml_namespaces.asp
Here's a list of similar question's
It is just like defining a namespace in C++,
A good explanation can be found here:
You need to use the namespace in case you use your own attributes for the views.
This is most commonly used when you create your own (or use others) customized views.
For example, if you create your own customized textView which supports using a custom font from the assets folder, you might want to add this:
<...MyTextView app:fontFile="fonts/myFont.ttf" .../>
Basically if you wont use the xmlns(ns: name space) ,there could be a conflict between the tag used in another xml file . for eg:
file1:
<table>
<name>jad</name>
</table>
file2:
<table>
<tr>
<td>google</td>
</tr>
</table>
If these XML fragments were added together, there would be a name conflict. Both contain a element, but the elements have different content and meaning.
For this major reason a qualified name space is used . There are other several use also .