Android Error [Attempt to invoke virtual method 'void android.app.ActionBar' on a null object reference]

后端 未结 24 2005
误落风尘
误落风尘 2020-11-28 22:13

I have a code module which implements viewpager with navigation drawer, however, when I run the code I get the following error

01-26 09:20:02.958: D/AndroidR         


        
24条回答
  •  星月不相逢
    2020-11-28 22:54

    Try doing this:

                    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
                    getSupportActionBar().setHomeButtonEnabled(true);
                    actionBar = getSupportActionBar();
                    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    

    Instead of this:

    actionBar = getSupportActionBar();
                    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    
                    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
                    getSupportActionBar().setHomeButtonEnabled(true);
    

提交回复
热议问题