Skip to content Skip to sidebar Skip to footer

Unexpected Namespace Prefix "xmlns" Found For Tag Listview

I added a list view under RelativeLayout in activity_main.xml to create a simple list view for the main activity (please excuse me if I am using wrong terminology. I am very new t

Solution 1:

You can remove the xmlns:android="http://schemas.android.com/apk/res/android" from your listview definition, it is only necessary once for the xml file.

    <ListView 
    android:id="@+id/listview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

xmlns is the namespace you are defining, in this case you are saying at the beginning of the file that "android" is linked to the namespace at

http://schemas.android.com/apk/res/android

so there is an error when you are attempting to redefine it

Solution 2:

To avoid this type of situation in future, I believe it's sufficient to inform the application only once about xml namespace at outermost Layout or View of xml file.

It's very odd because parser should reject any duplicate namespace declaration.

So you have to remove xmlns:android="http://schemas.android.com/apk/res/android from all the spaces (here ListView) except outermost Layout/View (here RelativeLayout)

OR

You can do a temporary solution by cleaning that project. Though it's a temporary solution, the plus point is that you don't have to do any code changes.

Post a Comment for "Unexpected Namespace Prefix "xmlns" Found For Tag Listview"