我开发了一个应用程序,我在其中使用导航抽屉,因为当我试图把项目的图标放到这样的图像的路径上时:“ RES/drawale/bg.jpg”。我没有得到如何做到这一点。如何把项目的图标放在导航抽屉里
下面是我的主要活动代码:
private void init_navigator() {
// Navigation Drawer
mTitle = mDrawerTitle = getTitle();
mDrawerLayout = (DrawerLayout) findViewById(R.id.main_activity_DrawerLayout);
mDrawerLayout.setStatusBarBackgroundColor(getResources().getColor(R.color.primaryDark));
mScrimInsetsFrameLayout = (ScrimInsetsFrameLayout) findViewById(R.id.main_activity_navigation_drawer_rootLayout);
mDrawerList = (ListView) findViewById(R.id.left_drawer);
mDrawerItmes = getResources().getStringArray(R.array.drawer_titles);
mDrawerItmes = getResources().getStringArray(R.array.nav_drawer_icons);
这里是XML我的string.xml
<string-array name="drawer_titles">
<item>About Us</item>
<item>FeedBack</item>
<item>Setting</item>
<item>Share App</item>
<item>Rate Us</item>
<item>Logout</item>
</string-array>
<array name="nav_drawer_icons">
<item>@drawable/bg</item>
<item>@drawable/bg</item>
<item>@drawable/bg</item>
<item>@drawable/bg</item>
<item>@drawable/b</item>
<item>@drawable/bg</item>
</array>
如果您正在使用navigationView,那么你可以很容易地创建一个菜单[带有标题和图标],并在t中膨胀菜单他导航视图作为一个xml属性 为了更加清晰看看http://www.technotalkative.com/part-4-playing-with-navigationview/ –
但在这里我怎么能给..你有什么想法 – user6798766
DrawerLayout指持有菜单的持有人。你应该在xml中显式地添加一个导航视图(菜单),然后从那里膨胀菜单 –