Research Development
Research Development

Reputation: 904

Error parsing XML: unbound prefix how to fix this issue

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:card="http://schemas.android.com/apk/res-auto"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <!-- Header aligned to top -->


    <!-- Footer aligned to bottom -->

    <RelativeLayout
        android:id="@+id/footer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="#fffff"
        android:gravity="center" >

        <TextView
            android:id="@+id/copyrightext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:paddingBottom="5dp"
            android:paddingTop="5dp"
            android:singleLine="true"
            android:textColor="#ffffff"
            android:textSize="12dp" />

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="70dp"
            android:layout_height="14dp"
            android:layout_centerVertical="true"
            android:layout_toRightOf="@+id/copyrightext"
            android:src="@drawable/softagelogo_icon" />
    </RelativeLayout>

    <!-- Content below header and above footer -->

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@id/footer"
        android:gravity="center" >

        <com.example.softageinfraapp.PagerSlidingTabStrip
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:background="@drawable/tabbackground"
            app:pstsShouldExpand="true"
            app:pstsTextAllCaps="true" >
        </com.example.softageinfraapp.PagerSlidingTabStrip>

        <android.support.v4.view.ViewPager
            android:id="@+id/viewpager"
            android:layout_width="match_parent"
            android:layout_height="fill_parent"
            android:background="@android:color/black" />
    </RelativeLayout>

</RelativeLayout>

how to fix Error parsing XML: unbound prefix on custom am getting Error com.example.softageinfraapp.PagerSlidingTabStrip i have created on Custom class for tab but i am getting Error i dont know how to fix it please help me or suggest me where am doing wrong .

Upvotes: 1

Views: 1227

Answers (3)

Bunny
Bunny

Reputation: 586

You are using "app" namespace in your following customview.

<com.example.softageinfraapp.PagerSlidingTabStrip
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:background="@drawable/tabbackground"
        app:pstsShouldExpand="true"
        app:pstsTextAllCaps="true" >
</com.example.softageinfraapp.PagerSlidingTabStrip>

So try changing your parent main layout like below.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
       xmlns:app="http://schemas.android.com/apk/res-auto"
       xmlns:app1="http://schemas.android.com/apk/res/yourpackagename"
       android:id="@+id/container"
       android:layout_width="match_parent"
       android:layout_height="match_parent" >

Also checkout this: frequent issues arising in android view, Error parsing XML: unbound prefix

Upvotes: 0

Raghunandan
Raghunandan

Reputation: 133570

You need to define a custom name space

 <com.example.softageinfraapp.PagerSlidingTabStrip
 xmlns:app="http://schemas.android.com/apk/res/yourpackagename"
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:background="@drawable/tabbackground"
        app:pstsShouldExpand="true"
        app:pstsTextAllCaps="true" >

More on this @ http://developer.android.com/training/custom-views/create-view.html

Upvotes: 1

Blackbelt
Blackbelt

Reputation: 157487

you have declared xmlns:card for the auto name space, but for the custom attributes of your PagerSlidingTabStrip you are using app:. You have to be consistent. You can either replace card with app or use card:

Upvotes: 1

Related Questions