我想更改导航抽屉图标。但是在更改图标之后,应用程序崩溃了。错误代码显示了一些布尔值,我很遗憾地不明白。我找不到失败。我以错误的方式实施了吗?抱歉,但是我是Android Studio的新手,这个问题可能有点不必要。但是尝试了很多解决问题。但是,我还找不到解决方案。
这是主要批准。我在OnCreate-Method之外产生了一个变量。
public class MainActivity extends AppCompatActivity {
private DrawerLayout mDrawerLayout;
ExpandableListAdapter mMenuAdapter;
ExpandableListView expandableList;
List<ExpandedMenuModel> listDataHeader;
HashMap<ExpandedMenuModel, List<String>> listDataChild;
ActionBarDrawerToggle mDrawerToggle;
Drawable drawable;
WebView webView;
Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_navigation_view);
mDrawerToggle.setDrawerIndicatorEnabled(false);
drawable = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_menu_gallery, getTheme());
mDrawerToggle.setHomeAsUpIndicator(drawable);
mDrawerToggle.setToolbarNavigationClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mDrawerLayout.isDrawerVisible(GravityCompat.START)) {
mDrawerLayout.closeDrawer(GravityCompat.START);
} else {
mDrawerLayout.openDrawer(GravityCompat.START);
}
}
});
........
mDrawerToggle = ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close);
mDrawerToggle.setDrawerIndicatorEnabled(false);
mDrawerToggle.setToolbarNavigationClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mDrawerLayout.isDrawerVisible(GravityCompat.START)) {
mDrawerLayout.closeDrawer(GravityCompat.START);
} else {
mDrawerLayout.openDrawer(GravityCompat.START);
}
}
});
mDrawerToggle.setHomeAsUpIndicator(R.drawable.ic_menu_gallery);
有关更多信息,请检查此链接
您尚未将值分配给:
mDrawerToggle
在此处致电setDrawerIndicatorEnabled
之前:
mDrawerToggle.setDrawerIndicatorEnabled(false);