Android ActionToggle图像未显示
我正在实现Android ActionToggle图像未显示,android,android-actionbar,navigation-drawer,Android,Android Actionbar,Navigation Drawer,我正在实现ActionTogglebutton以显示抽屉。虽然抽屉在点击切换按钮时显示,但在切换按钮位置上显示图像或什么都没有 这是我的密码 actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.drawable.kooveicon) { public void onDrawerClosed(View view) { getActionBa
ActionTogglebutton
以显示抽屉。虽然抽屉在点击切换按钮时显示,但在切换按钮位置上显示图像或什么都没有
这是我的密码
actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.drawable.kooveicon) {
public void onDrawerClosed(View view) {
getActionBar().setTitle(getTitle());
getActionBar().setDisplayShowHomeEnabled(false);
getActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setTitle("Closed");
invalidateOptionsMenu();
}
public void onDrawerOpened(View drawerView) {
getSupportActionBar().setDisplayShowHomeEnabled(false);
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setTitle("Browse Items");
invalidateOptionsMenu();
}
};
完全按照以下方式更新您的代码:
actionBar = getSupportActionBar();
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
mDrawerLayout = (DrawerLayout) findViewById(R.id.my_drawer_layout);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
mDrawerToggle.setDrawerIndicatorEnabled(true);
mDrawerLayout.setDrawerListener(mDrawerToggle);
并在类中添加另一个方法onPostCreate()[这是抽屉指示器动画]
@Override
protected void onPostCreate(Bundle savedInstanceState)
{
super.onPostCreate(savedInstanceState);
mDrawerToggle.syncState();
}
希望这有帮助 设置是否显示HomeAsupEnabled(true)和actionBarDrawerToggle.setDrawerIndicatorEnabled(true);仍然不显示图像它工作正常,但不显示图像。