zoukankan      html  css  js  c++  java
  • Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.setHomeButtonEnabled(boolean)' on a null object reference

    【Android】getActionBar()为null的解决方法总结

    setContentView(R.layout.activity_main);
    android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setIcon(R.mipmap.ic_launcher_finish);

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.qindou.currenciesnc/com.qindou.currenciesnc.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.setHomeButtonEnabled(boolean)' on a null object reference
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
    at android.app.ActivityThread.-wrap11(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
    at android.os.Handler.dispatchMessage(Handler.java:105)
    at android.os.Looper

    这个又是版本的问题吗?山高路远坑深啊!

  • 相关阅读:
    HDU 5714
    C++ 中的名称冲突之 "y1"
    FFT 模板
    Modular Query
    找礼物(find)(模拟)
    水流(water)(BFS)(DFS)
    单词接龙(dragon)(BFS)
    细菌(disease) (位运算)(状态压缩)
    Diamond Collector (动态规划)
    超级素数(sprime) (BFS)
  • 原文地址:https://www.cnblogs.com/qingdou/p/8094566.html
Copyright © 2011-2022 走看看