xml文件属性无缘 [英] Xml file missed attributes

查看:164
本文介绍了xml文件属性无缘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我导入库从这里:

https://github.com/47deg/android-swipelistview

然后我创建与和背部标识的XML文件:

then i created an xml file with from and back id:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
             >

    <RelativeLayout 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/front"
            android:tag="front" >

            <ImageView
                android:id="@+id/ImageView01"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                 />

            <TextView
                android:id="@+id/TextView01"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/ImageView01"
                android:layout_centerHorizontal="true"
                android:textSize="18sp"
                android:textStyle="bold"
                android:inputType="textMultiLine" />

        </RelativeLayout>


            <LinearLayout
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:orientation="horizontal"
                      android:id="@+id/back"
                     android:tag="back"

                      >

                      <Button
                          android:id="@+id/deleteBtn1"
                          android:layout_width="150dp"
                          android:layout_height="100dp"
                          android:text="Delete" />

                      <Button
                          android:id="@+id/UpdateBtn1"
                          android:layout_width="150dp"
                          android:layout_height="100dp"
                          android:text="Update" />

                  </LinearLayout>

</LinearLayout>

然后我创建的swipeListView XML文件:

and then i created the xml file with the swipeListView:

<?xml version="1.0" encoding="utf-8"?>

   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/linearLayout1"
        android:orientation="vertical" >

                <EditText android:id="@+id/EditText01"
                                android:layout_height="wrap_content"
                                android:layout_width="fill_parent"
                                android:hint="Search">                               
                </EditText>

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


        <main.java.com.fortysevendeg.android.swipelistview.SwipeListView
            xmlns:swipe="http://schemas.android.com/apk/res-auto"
            android:id="@+id/example_lv_list"
            android:listSelector="#00000000"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            swipe:swipeFrontView="@+id/front"
            swipe:swipeBackView="@+id/back"
            swipe:swipeActionLeft="dismiss"
            swipe:swipeCloseAllItemsWhenMoveList="true"
            swipe:swipeMode="both"
            />


    </LinearLayout>

和它为我的错误:

The following classes could not be instantiated:
- main.java.com.fortysevendeg.android.swipelistview.SwipeListView (Open Class, Show Error Log)
See the Error Log (Window > Show View) for more details.
Tip: Use View.isInEditMode() in your custom views to skip code when shown in Eclipse

java.lang.RuntimeException: Missed attribute swipeFrontView or swipeBackView
    at main.java.com.fortysevendeg.android.swipelistview.SwipeListView.init(SwipeListView.java:166)
    at main.java.com.fortysevendeg.android.swipelistview.SwipeListView.<init>(SwipeListView.java:121)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(    at sun.reflect.NativeConstructorAccessorImpl.newInstance(    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(    at java.lang.reflect.Constructor.newInstance(    at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.instantiateClass(ProjectCallback.java:422)
    at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.loadView(ProjectCallback.java:179)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:135)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:746)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:718)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:372)

行166:

    throw new RuntimeException("Missed attribute swipeFrontView or swipeBackView");

 if (swipeFrontView == 0 || swipeBackView == 0) {
            throw new RuntimeException("Missed attribute swipeFrontView or swipeBackView");
        }

和行121是:

init(attrs);


public SwipeListView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(attrs);
    }

很多

推荐答案

ADIR我相信这个问题可能是您正在尝试使用无效的包名称标识符实例化错误的类。 main.java。 com.fortysevendeg.android.swipelistview.SwipeListView

Adir I believe the issue may be that you are trying to instantiate the wrong class by using an invalid package name identifier. main.java.com.fortysevendeg.android.swipelistview.SwipeListView

从类名称中删除main.java。

Remove main.java from the class name.

这篇关于xml文件属性无缘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆