我隐藏了如下所示的标题栏,它可以正常工作。
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
}
}
但是,当我长时间点击并在webView或editText中启动单词选择时,应用程序将会崩溃。
: E/AndroidRuntime(30416): FATAL EXCEPTION: main
: Process: com.example.aaa, PID: 30416
: java.lang.NullPointerException
: at android.support.v7.app.ActionBarImplICS.getThemedContext(ActionBarImplICS.java:302)
: at android.support.v7.app.ActionBarImplJB.getThemedContext(ActionBarImplJB.java:20)
: at android.support.v7.app.ActionBarActivityDelegate.getActionBarThemedContext(ActionBarActivityDelegate.java:210)
: at android.support.v7.app.ActionBarActivityDelegateICS.onActionModeStarted(ActionBarActivityDelegateICS.java:195)
: at android.support.v7.app.ActionBarActivityDelegateICS$WindowCallbackWrapper.onActionModeStarted(ActionBarActivityDelegateICS.java:359)
: at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionMode(PhoneWindow.java:2441)
: at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionModeForChild(PhoneWindow.java:2366)
: at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:665)
: at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:665)
: at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:665)
: at android.view.View.startActionMode(View.java:4585)
: at android.widget.Editor.startSelectionActionMode(Editor.java:1619)
: at android.widget.Editor.performLongClick(Editor.java:883)
: at android.widget.TextView.performLongClick(TextView.java:8681)
: at android.view.View$CheckForLongPress.run(View.java:18725)
: at android.os.Handler.handleCallback(Handler.java:733)
: at android.os.Handler.dispatchMessage(Handler.java:95)
: at android.os.Looper.loop(Looper.java:149)
: at android.app.ActivityThread.main(ActivityThread.java:5257)
: at java.lang.reflect.Method.invokeNative(Native Method)
: at java.lang.reflect.Method.invoke(Method.java:515)
: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:788)
: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:604)
: at dalvik.system.NativeStart.main(Native Method)
我认为这是因为单词选择使用Titlebar
。
我该如何解决?
答案 0 :(得分:0)
是您的活动扩展了ActionbarActivity。 如果"是"那么你需要编写自定义主题。