Android 分析XML时出错:未绑定前缀如何解决此问题

Android 分析XML时出错:未绑定前缀如何解决此问题,android,Android,如何修复解析XML时的错误:自定义上的未绑定前缀我在自定义类上为tab创建了错误com.example.softageinfraapp.pagerslidingtastrip,但我遇到错误我不知道如何修复,请帮助我或建议我哪里做错了。您已经为自动名称空间声明了xmlns:card,但是对于PagerSlidingTabStrip的自定义属性,您使用的是app:。你必须始终如一。您可以使用app替换card,也可以使用card:您需要定义一个自定义名称空间 <?xml version="1.

如何修复解析XML时的错误:自定义上的未绑定前缀我在自定义类上为tab创建了错误com.example.softageinfraapp.pagerslidingtastrip,但我遇到错误我不知道如何修复,请帮助我或建议我哪里做错了。

您已经为自动名称空间声明了
xmlns:card
,但是对于
PagerSlidingTabStrip
的自定义属性,您使用的是
app:
。你必须始终如一。您可以使用
app
替换
card
,也可以使用
card:

您需要定义一个自定义名称空间

<?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>

有关此@

的详细信息,您正在以下customview中使用“app”命名空间

 <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" >

因此,请尝试更改您的父主布局,如下所示

<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>

也请检查以下内容:

<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" >