android.support.v7.app.ActionBarImplICS.getThemedContext Android中的NullPointerException

时间:2014-03-15 22:45:02

标签: java android exception nullpointerexception

请帮助我获取java.lang.NullPointerException 在Google Play开发者控制台的android.support.v7.app.ActionBarImplICS.getThemedContext中,但是当我测试它时,我没有收到任何错误或崩溃,请告诉我导致崩溃的原因以及如何解决问题。错误如下所示,如果需要,我也可以共享代码。

    java.lang.NullPointerException
at android.support.v7.app.ActionBarImplICS.getThemedContext(ActionBarImplICS.java:287)
at android.support.v7.app.ActionBarImplJB.getThemedContext(ActionBarImplJB.java:20)
at android.support.v7.app.ActionBarActivityDelegate.getActionBarThemedContext(ActionBarActivityDelegate.java:207)
at android.support.v7.app.ActionBarActivityDelegateICS.onActionModeStarted(ActionBarActivityDelegateICS.java:196)
at android.support.v7.app.ActionBarActivityDelegateICS$WindowCallbackWrapper.onActionModeStarted(ActionBarActivityDelegateICS.java:351)
at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionMode(PhoneWindow.java:2292)
at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionModeForChild(PhoneWindow.java:2215)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:619)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:619)
at android.view.View.startActionMode(View.java:4191)
at android.webkit.WebViewClassic.startSelectActionMode(WebViewClassic.java:5049)
at android.webkit.WebViewClassic.setupWebkitSelect(WebViewClassic.java:5178)
at android.webkit.WebViewClassic.updateTextSelectionFromMessage(WebViewClassic.java:7929)
at android.webkit.WebViewClassic.access$4300(WebViewClassic.java:147)
at android.webkit.WebViewClassic$PrivateHandler.handleMessage(WebViewClassic.java:7249)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)

2 个答案:

答案 0 :(得分:9)

这解决了我https://stackoverflow.com/a/19320065/619673

的问题

我为我的活动添加了此代码,因为我使用的是主题" NO TITLE"活动。

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ( keyCode == KeyEvent.KEYCODE_MENU ) {
        // do nothing
        return true;
    }
    return super.onKeyDown(keyCode, event);
}  

答案 1 :(得分:2)

public class MainActivity extends ActionBarActivity

将其更改为:

public class MainActivity extends Activity