AndroidStaggeredGrid
AndroidStaggeredGrid copied to clipboard
NullPointerException on LongClick in Edittext
- add header view
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/red">
<EditText
android:id="@+id/txt_title"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_weight="1"
android:gravity="center" />
- Long Click in EditText
- throw Exception.
java.lang.NullPointerException at android.widget.AbsListView.showContextMenuForChild(AbsListView.java:2891) at android.view.ViewGroup.showContextMenuForChild(ViewGroup.java:647) at android.view.ViewGroup.showContextMenuForChild(ViewGroup.java:647) at android.view.View.showContextMenu(View.java:4310) at android.view.View.performLongClick(View.java:4279) at android.widget.TextView.performLongClick(TextView.java:8250) at android.view.View$CheckForLongPress.run(View.java:17700) at android.os.Handler.handleCallback(Handler.java:730) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5103) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) at dalvik.system.NativeStart.main(Native Method)
my env ANDROID_BUILD_MIN_SDK_VERSION=15 ANDROID_BUILD_TARGET_SDK_VERSION=21 ANDROID_BUILD_TOOLS_VERSION=21.1.2 ANDROID_BUILD_SDK_VERSION=21
thz~
I got the same issue.I could fix this by setting font of the view(Editext/Textview) programmatically instead of XML.Please note that for me it was only happening on lollipop versions of Samsung reported by crashlytics.