I have implemented drag-sort-listview in android studio. It is working fine on onclick and drag and drop but the app is crashing onlongclick.
AndroidRuntime: FATAL EXCEPTION: main
Process: com.pixelpoint, PID: 27677
java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.view.ActionMode$Callback.onCreateActionMode(android.view.ActionMode, android.view.Menu)' on a null object reference
at com.android.internal.policy.PhoneWindow$DecorView$ActionModeCallback2Wrapper.onCreateActionMode(PhoneWindow.java:3531)
at android.support.v7.view.SupportActionModeWrapper$CallbackWrapper.onCreateActionMode(SupportActionModeWrapper.java:155)
at android.support.v7.app.AppCompatDelegateImplV7$ActionModeCallbackWrapperV7.onCreateActionMode(AppCompatDelegateImplV7.java:1742)
at android.support.v7.app.AppCompatDelegateImplV7.startSupportActionModeFromWindow(AppCompatDelegateImplV7.java:802)
at android.support.v7.app.AppCompatDelegateImplV7.startSupportActionMode(AppCompatDelegateImplV7.java:696)
at android.support.v7.app.AppCompatDelegateImplV14$AppCompatWindowCallbackV14.startAsSupportActionMode(AppCompatDelegateImplV14.java:187)
at android.support.v7.app.AppCompatDelegateImplV23$AppCompatWindowCallbackV23.onWindowStartingActionMode(AppCompatDelegateImplV23.java:64)
at com.android.internal.policy.PhoneWindow$DecorView.startActionMode(PhoneWindow.java:2748)
at com.android.internal.policy.PhoneWindow$DecorView.startActionModeForChild(PhoneWindow.java:2729)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:812)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:812)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:812)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:812)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:812)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:812)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:812)
at android.view.View.startActionMode(View.java:5335)
at android.view.View.startActionMode(View.java:5319)
at android.widget.AbsListView.performLongPress(AbsListView.java:3118)
at android.widget.AbsListView$CheckForLongPress.run(AbsListView.java:3059)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
I have implemented drag-sort-listview in android studio. It is working fine on onclick and drag and drop but the app is crashing onlongclick.
AndroidRuntime: FATAL EXCEPTION: main Process: com.pixelpoint, PID: 27677 java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.view.ActionMode$Callback.onCreateActionMode(android.view.ActionMode, android.view.Menu)' on a null object reference at com.android.internal.policy.PhoneWindow$DecorView$ActionModeCallback2Wrapper.onCreateActionMode(PhoneWindow.java:3531) at android.support.v7.view.SupportActionModeWrapper$CallbackWrapper.onCreateActionMode(SupportActionModeWrapper.java:155) at android.support.v7.app.AppCompatDelegateImplV7$ActionModeCallbackWrapperV7.onCreateActionMode(AppCompatDelegateImplV7.java:1742) at android.support.v7.app.AppCompatDelegateImplV7.startSupportActionModeFromWindow(AppCompatDelegateImplV7.java:802) at android.support.v7.app.AppCompatDelegateImplV7.startSupportActionMode(AppCompatDelegateImplV7.java:696) at android.support.v7.app.AppCompatDelegateImplV14$AppCompatWindowCallbackV14.startAsSupportActionMode(AppCompatDelegateImplV14.java:187) at android.support.v7.app.AppCompatDelegateImplV23$AppCompatWindowCallbackV23.onWindowStartingActionMode(AppCompatDelegateImplV23.java:64) at com.android.internal.policy.PhoneWindow$DecorView.startActionMode(PhoneWindow.java:2748) at com.android.internal.policy.PhoneWindow$DecorView.startActionModeForChild(PhoneWindow.java:2729) at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:812) at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:812) at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:812) at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:812) at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:812) at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:812) at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:812) at android.view.View.startActionMode(View.java:5335) at android.view.View.startActionMode(View.java:5319) at android.widget.AbsListView.performLongPress(AbsListView.java:3118) at android.widget.AbsListView$CheckForLongPress.run(AbsListView.java:3059) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)