我正在尝试使用MaterialDrawer库将汉堡包图标添加到工具栏中。我可以用下面的代码将图标--图标--放入工具栏
// Handle Toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_action_name);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);在那之前,我创造了一个抽屉
Drawer result = new DrawerBuilder()
...
.build();最后,我使用图书馆的说明添加了汉堡包图标。
result.getActionBarDrawerToggle().setDrawerIndicatorEnabled(true);当我执行代码时,它会在las行中给出以下错误,而不运行应用程序
无法启动活动ComponentInfo{com.example.sergi.drawerexample/com.example.sergi.drawerexample.MainActivity}:java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法的空android.support.v7.app.ActionBarDrawerToggle.setDrawerIndicatorEnabled(boolean)‘
有人能帮我,我不知道会发生什么
谢谢
发布于 2018-05-19 09:28:34
https://stackoverflow.com/questions/50407606
复制相似问题