Android Swipelistview不工作
我正试图在我的项目中使用,但它会说:Android Swipelistview不工作,android,listview,swipe,ontouchlistener,swipe-gesture,Android,Listview,Swipe,Ontouchlistener,Swipe Gesture,我正试图在我的项目中使用,但它会说: java.lang.NullPointerException at com.fortysevendeg.swipelistview.SwipeListViewTouchListener.setFrontView(SwipeListViewTouchListener.java:138) at com.fortysevendeg.swipelistview.SwipeListViewTouchListener.onTouch(SwipeListViewTouch
java.lang.NullPointerException
at com.fortysevendeg.swipelistview.SwipeListViewTouchListener.setFrontView(SwipeListViewTouchListener.java:138)
at com.fortysevendeg.swipelistview.SwipeListViewTouchListener.onTouch(SwipeListViewTouchListener.java:731)
at com.fortysevendeg.swipelistview.SwipeListView.onInterceptTouchEvent(SwipeListView.java:630)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1852)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
在android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)中
位于android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1910)
在android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)中
我以以下方式实现了该库:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.fortysevendeg.swipelistview.SwipeListView
xmlns:swipe="http://schemas.android.com/apk/res-auto"
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="35dp"
android:layout_marginTop="51dp"
android:listSelector="#00000000"
swipe:swipeActionLeft="dismiss"
swipe:swipeActionRight="dismiss"
swipe:swipeAnimationTime="1000"
swipe:swipeBackView="@+id/back"
swipe:swipeCloseAllItemsWhenMoveList="false"
swipe:swipeFrontView="@+id/front"
swipe:swipeMode="both"
swipe:swipeOffsetLeft="20dp"
swipe:swipeOffsetRight="20dp"
swipe:swipeOpenOnLongPress="false" />
</LinearLayout>
这不应该
States states_name[] = new States[]
是这个吗
States[] states_name = new States[]
布局中可能缺少在com.fortysevendeg.swipelistview.swipelistview实现中指定的id为“front”和“back”的元素。它们应该在listview行布局中,在您的情况下,它应该是“R.layout.listtoinflate”,这是您在适配器中拥有的 这里有一些示例代码: 此线程中也会回答此问题:
但这不是问题所在。如果我删除此项,列表将正常工作。我无法摆脱上面提到的nullpointer异常。@GDroid您也可以在这里快速查看一下。我面临着完全相同的问题。关于如何解决这个问题有什么建议吗?@androidbug:试试。这很简单,可以帮你完成工作。我找到了解决办法@我的布局中缺少id/前面和@id/后面。我加了一句,效果很好:)你能告诉我@+id/前面和@+id/后面是什么吗?它们是否引用了同一xml文件中的布局?在xml中设置此listview时遇到问题
States[] states_name = new States[]