我在styles.xml

时间:2016-09-10 02:00:25

标签: android android-actionbar

我对操作栏进行了一些更改,然后该应用程序无法正常工作。

它说

  

引起:java.lang.NullPointerException:尝试调用虚拟   方法' android.view.View android.view.Window.getDecorView()'在...上   null对象引用

我不知道该怎么做。

这是logcat日志

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.george.photoeditor/com.example.gentaliu.photoeditor.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.Window.getDecorView()' on a null object reference                                                                  
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2357)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
  at android.app.ActivityThread.access$1200(ActivityThread.java:165)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1373)
  at android.os.Handler.dispatchMessage(Handler.java:102)
  at android.os.Looper.loop(Looper.java:135)
  at android.app.ActivityThread.main(ActivityThread.java:5593)
  at java.lang.reflect.Method.invoke(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:372)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.Window.getDecorView()' on a null object reference
  at android.app.Activity.initWindowDecorActionBar(Activity.java:2162)
  at android.app.Activity.getActionBar(Activity.java:2122)
  at com.example.gentaliu.photoeditor.MainActivity.<init>(MainActivity.java:42)
  at java.lang.reflect.Constructor.newInstance(Native Method)
  at java.lang.Class.newInstance(Class.java:1606)
  at android.app.Instrumentation.newActivity(Instrumentation.java:1066)
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2347)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512) 
  at android.app.ActivityThread.access$1200(ActivityThread.java:165) 
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1373) 
  at android.os.Handler.dispatchMessage(Handler.java:102) 
  at android.os.Looper.loop(Looper.java:135) 
  at android.app.ActivityThread.main(ActivityThread.java:5593) 
  at java.lang.reflect.Method.invoke(Native Method) 
  at java.lang.reflect.Method.invoke(Method.java:372)

这是我做出更改的styles.xml代码:

style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>


<style name="AppTheme.ActionBar" parent="Widget.AppCompat.ActionBar">
    <item name="android:action">false</item>
    <item name="windowNoTitle">true</item>

0 个答案:

没有答案