简体   繁体   中英

Android Libraries and custom xml attributes

I want to use a library to make drag and drop list view. It's named "drag-sort-list-view" After download this lib project,I created a project and I exported de libray folder in .jar, including the .classes and the xml dslv_attrs, containing the styleable. I can't compile with it. Look at my xml where i want to use the custom :

<?xml version="1.0" encoding="utf-8"?>
<com.mobeta.android.dslv.DragSortListView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:dslv="http://schemas.android.com/apk/res/com.mobeta.android.dslv"
    android:id="@android:id/list"
      android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    dslv:drag_enabled="true"
    dslv:collapsed_height="2dp"
    dslv:drag_scroll_start="0.33"
    dslv:max_drag_scroll_speed="0.5"
    dslv:float_alpha="0.6"
    dslv:slide_shuffle_speed="0.3"
    dslv:track_drag_sort="false"
    dslv:use_default_controller="true"
    dslv:drag_handle_id="@id/drag_handle"
    dslv:sort_enabled="true"
    dslv:remove_enabled="true"
    dslv:drag_start_mode="onDown"
    dslv:remove_mode="flingRemove" />

for the line xmlns:dslv , if I set my package project I have this kind of error :

error: No resource identifier found for attribute 'xxx' in package 

Every where i read it's the fix of the issue...

When I set the library project, like on the example, it compile and stop with this error in the logcat :

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.interfacevm/com.example.interfacevm.MainActivity}: android.view.InflateException: Binary XML 
                                  file line #2: Error inflating class com.mobeta.android.dslv.DragSortListView

I read that there 'is a fix for this issur in sdk 17, but it doesn't work for me. An idea ? Thanks a lot

It's just a guess, but try to replace the namespace with

xmlns:dslv="http://schemas.android.com/apk/res-auto"

That's how i import my libraries and that works fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM