我决定从拥有库项目切换到在我的 libs 目录中拥有 JAR。除了我正在使用的DragSortListView 库之外,这对每个库都适用。当我运行我的应用程序时,我得到一个必须膨胀InflateException
的类。DragSortListView
我必须更改 XML 布局,以便可以使用属性DragSortListView
(我所做的唯一更改是对 xmlns:dslv 行)。还值得注意的是,我可以DragSortListView
在 java 文件中使用该类
XML 布局(作为项目的库):
<com.mobeta.android.dslv.DragSortListView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dslv="http://schemas.android.com/apk/res/com.package.myprojectpackage"
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawSelectorOnTop="false"
dslv:collapsed_height="2dp"
dslv:drag_enabled="true"
dslv:drag_scroll_start="1"
dslv:float_alpha="1.0"
dslv:float_background_color="@color/Transparent"
dslv:max_drag_scroll_speed="0.5"
dslv:slide_shuffle_speed="0.3"
dslv:drag_handle_id="@+id/sabnzbd_queue_drag_handle"
dslv:track_drag_sort="false"
dslv:use_default_controller="true" />
XML 布局(作为 JAR 的库):
<com.mobeta.android.dslv.DragSortListView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dslv="http://schemas.android.com/apk/lib/com.mobeta.android.dslv"
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawSelectorOnTop="false"
dslv:collapsed_height="2dp"
dslv:drag_enabled="true"
dslv:drag_scroll_start="1"
dslv:float_alpha="1.0"
dslv:float_background_color="@color/Transparent"
dslv:max_drag_scroll_speed="0.5"
dslv:slide_shuffle_speed="0.3"
dslv:drag_handle_id="@+id/sabnzbd_queue_drag_handle"
dslv:track_drag_sort="false"
dslv:use_default_controller="true" />
InflateException(作为 JAR 的库):
07-06 15:25:33.376: E/AndroidRuntime(22907): FATAL EXCEPTION: main
07-06 15:25:33.376: E/AndroidRuntime(22907): android.view.InflateException: Binary XML file line #32: Error inflating class com.mobeta.android.dslv.DragSortListView
07-06 15:25:33.376: E/AndroidRuntime(22907): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
07-06 15:25:33.376: E/AndroidRuntime(22907): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
07-06 15:25:33.376: E/AndroidRuntime(22907): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
07-06 15:25:33.376: E/AndroidRuntime(22907): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
07-06 15:25:33.376: E/AndroidRuntime(22907): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
07-06 15:25:33.376: E/AndroidRuntime(22907): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
如果有人可以解释为什么无法在 XML 文件中找到该类,并可能提供有关如何解决该问题的解决方案,将不胜感激!