android-swipelistview-sharp icon indicating copy to clipboard operation
android-swipelistview-sharp copied to clipboard

Error on click on the list

Open emas00 opened this issue 8 years ago • 2 comments

I am getting this error when I try to click the list. Maybe you could know what is the issue. Thanks

Attempt to invoke virtual method void android.view.View.setOnClickListener(android.view.View$OnClickListener) on a null object reference


Exception dispatching input event. java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setOnClickListener(android.view.View$OnClickListener)' on a null object reference at com.fortysevendeg.swipelistview.SwipeListViewTouchListener.setFrontView(SwipeListViewTouchListener.java:142) at com.fortysevendeg.swipelistview.SwipeListViewTouchListener.onTouch(SwipeListViewTouchListener.java:781) at com.fortysevendeg.swipelistview.SwipeListView.onInterceptTouchEvent(SwipeListView.java:653) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2109) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2198) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2198) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2198) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2198) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2198) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2198) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2198) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2198) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2198) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2554) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2198) at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2410) at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1744) at android.app.Activity.dispatchTouchEvent(Activity.java:2805) at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60) at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60) at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2371) at android.view.View.dispatchPointerEvent(View.java:9597) at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4234) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4100) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3646) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3699) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3665) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3791) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3673) at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3848) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3646) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3699) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3665) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3673) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3646) at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5926) at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5900) at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5861) at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6029) at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185) at android.os.MessageQueue.nativePollOnc Shutting down VM Unhandled Exception:

Java.Lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setOnClickListener(android.view.View$OnClickListener)' on a null object reference

emas00 avatar Oct 13 '16 21:10 emas00

I am having the same issue here.

I have followed the example to implement the component in my app. However, the layout in which I added the SwipeListView is inflated in a fragment. Is this the reason for the "Attempt to invoke virtual method void android.view.View.setOnClickListener(android.view.View$OnClickListener) on a null object reference" error ?

Have you got a solution or workaround?

macrovivero avatar Dec 07 '16 18:12 macrovivero

I made my app work, it also inflates the layout in a fragment so that is not the problem. Make sure that in your cell layout you have all the controls for the front and back view of the swipelist.

Cell layout

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent">

<LinearLayout
    android:orientation="horizontal"
    android:id="@+id/back"
    android:tag="back"
    android:gravity="left|center"
    android:paddingLeft="8dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">		
    <!--Your controls for the back-->		
</LinearLayout>

<LinearLayout
    android:id="@+id/front"
    android:tag="front"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#ffffff"
    android:weightSum="100">    
<!--Your controls for the front-->	
</LinearLayout>

Be sure that you put the correct id for the front and back controls in the swipelist attributes.

Swipe list layout

<com.fortysevendeg.swipelistview.SwipeListView android:id="@+id/example_lv_list" android:listSelector="#00000000" android:layout_width="fill_parent" android:layout_height="wrap_content" app:swipeFrontView="@+id/front" app:swipeBackView="@+id/back app:swipeCloseAllItemsWhenMoveList="true" app:swipeMode="both" app:swipeActionRight="reveal" app:swipeActionLeft="reveal" app:swipeOpenOnLongPress="false" />

Hope this help you.

emas00 avatar Dec 08 '16 18:12 emas00