0

I have an edit text. While I am trying to long press on edittext the app crashes, it gives the following log:

08-12 10:42:51.503: E/AndroidRuntime(838): FATAL EXCEPTION: main
08-12 10:42:51.503: E/AndroidRuntime(838): java.lang.NullPointerException
08-12 10:42:51.503: E/AndroidRuntime(838):  at  android.support.v7.app.ActionBarImplICS.getThemedContext(ActionBarImplICS.java:302)
08-12 10:42:51.503: E/AndroidRuntime(838):  at android.support.v7.app.ActionBarImplJB.getThemedContext(ActionBarImplJB.java:20)
08-12 10:42:51.503: E/AndroidRuntime(838):  at android.support.v7.app.ActionBarActivityDelegate.getActionBarThemedContext(ActionBarActivityDelegate.java:208)
08-12 10:42:51.503: E/AndroidRuntime(838):  at android.support.v7.app.ActionBarActivityDelegateICS.onActionModeStarted(ActionBarActivityDelegateICS.java:195)
08-12 10:42:51.503: E/AndroidRuntime(838):  at android.support.v7.app.ActionBarActivityDelegateICS$WindowCallbackWrapper.onActionModeStarted(ActionBarActivityDelegateICS.java:359)
08-12 10:42:51.503: E/AndroidRuntime(838):  at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionMode(PhoneWindow.java:2342)
08-12 10:42:51.503: E/AndroidRuntime(838):  at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionModeForChild(PhoneWindow.java:2260)
08-12 10:42:51.503: E/AndroidRuntime(838):  at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:654)
08-12 10:42:51.503: E/AndroidRuntime(838):  at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:654)
08-12 10:42:51.503: E/AndroidRuntime(838):  at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:654)
08-12 10:42:51.503: E/AndroidRuntime(838):  at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:654)
08-12 10:42:51.503: E/AndroidRuntime(838):  at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:654)
08-12 10:42:51.503: E/AndroidRuntime(838):  at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:654)
08-12 10:42:51.503: E/AndroidRuntime(838):  at android.view.View.startActionMode(View.java:4519)
08-12 10:42:51.503: E/AndroidRuntime(838):  at android.widget.Editor.startSelectionActionMode(Editor.java:1524)
08-12 10:42:51.503: E/AndroidRuntime(838):  at android.widget.Editor.performLongClick(Editor.java:845)
08-12 10:42:51.503: E/AndroidRuntime(838):  at android.widget.TextView.performLongClick(TextView.java:8268)
08-12 10:42:51.503: E/AndroidRuntime(838):  at android.view.View$CheckForLongPress.run(View.java:17882)
08-12 10:42:51.503: E/AndroidRuntime(838):  at android.os.Handler.handleCallback(Handler.java:730)
08-12 10:42:51.503: E/AndroidRuntime(838):  at android.os.Handler.dispatchMessage(Handler.java:92)
08-12 10:42:51.503: E/AndroidRuntime(838):  at android.os.Looper.loop(Looper.java:137)
08-12 10:42:51.503: E/AndroidRuntime(838):  at android.app.ActivityThread.main(ActivityThread.java:5214)
08-12 10:42:51.503: E/AndroidRuntime(838):  at java.lang.reflect.Method.invokeNative(Native Method)
08-12 10:42:51.503: E/AndroidRuntime(838):  at java.lang.reflect.Method.invoke(Method.java:525)
08-12 10:42:51.503: E/AndroidRuntime(838):  at  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
08-12 10:42:51.503: E/AndroidRuntime(838):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
08-12 10:42:51.503: E/AndroidRuntime(838):  at dalvik.system.NativeStart.main(Native Method)  

I have no idea why it's happening.

Vulcronos
  • 3,428
  • 3
  • 16
  • 24
Rajesh Panchal
  • 1,140
  • 3
  • 20
  • 39

5 Answers5

0

Try this from here

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ( keyCode == KeyEvent.KEYCODE_MENU ) {
        // do nothing
        return true;
    }
    return super.onKeyDown(keyCode, event);
} 
Community
  • 1
  • 1
rupesh jain
  • 3,410
  • 1
  • 14
  • 22
  • @RajeshSuthar this issue seems to be fixed in https://code.google.com/p/android/issues/detail?id=61394..please make sure you are using latest version of library – rupesh jain Aug 12 '14 at 05:29
0

maybe you need getSupportActionbar() other than getActionbar()

01.sunlit
  • 305
  • 1
  • 2
  • 8
0

I have study about this problem and found that this problem is android OS bug and for solve that in your values/styles remove below code:

<item name="android:fontFamily">every things here</item>
Mohammad Jamali
  • 238
  • 3
  • 5
0

IF your EditText is wrapped with a TextInputLayout this may help you

It the TextInputLayout has a theme assigned make sure that its parent is

parent="Widget.Design.TextInputLayout"

This was my issue and after changing the parent it started working fine.

Aerim
  • 1,960
  • 3
  • 16
  • 28
0

Below is what worked for me...

1) If your EditText is wrapped with a TextInputLayout then add below property to your Edittext

android:longClickable = false

2) If you are using a custom style for your EditText then add below attribute to your custom style code.

<item name="android:longClickable">false</item>

Hope this helps.

Avi
  • 551
  • 5
  • 8