Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/217.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
默认Android Studio导航抽屉活动模板不显示汉堡图标,仅显示箭头图标_Android_Navigation Drawer_Hamburger Menu - Fatal编程技术网

默认Android Studio导航抽屉活动模板不显示汉堡图标,仅显示箭头图标

默认Android Studio导航抽屉活动模板不显示汉堡图标,仅显示箭头图标,android,navigation-drawer,hamburger-menu,Android,Navigation Drawer,Hamburger Menu,但是,提供的解决方案没有帮助,对我也不起作用,因为我的代码实际上正在调用mDrawerToggle.sycnState()(在延迟的Runnable中) 我还尝试将其添加到片段中创建的onActivityCreated中,但似乎没有任何作用。由于不知道syncState的具体功能,我无法判断它是否正在同步打开的状态(模板代码默认情况下会发生这种情况),然后当抽屉手动关闭时,它就再也不会同步了 我会发布代码,但您可以通过在Android Studio(1.2.2)中创建一个新项目来测试这一点,选择

但是,提供的解决方案没有帮助,对我也不起作用,因为我的代码实际上正在调用mDrawerToggle.sycnState()(在延迟的Runnable中)

我还尝试将其添加到片段中创建的onActivityCreated中,但似乎没有任何作用。由于不知道syncState的具体功能,我无法判断它是否正在同步打开的状态(模板代码默认情况下会发生这种情况),然后当抽屉手动关闭时,它就再也不会同步了


我会发布代码,但您可以通过在Android Studio(1.2.2)中创建一个新项目来测试这一点,选择导航抽屉活动,然后简单地运行该项目-无需更改。您将看到唯一的图标是我刚刚想出了一个解决方案,以防其他人遇到此问题:

将片段顶部的导入更改为

import android.support.v4.app.ActionBarDrawerToggle;

然后从中更改安装程序中的代码

mDrawerToggle = new ActionBarDrawerToggle(
            getActivity(),                    /* host Activity */
            mDrawerLayout,                    /* DrawerLayout object */
            R.drawable.ic_drawer,             /* nav drawer image to replace 'Up' caret */
            R.string.navigation_drawer_open,  /* "open drawer" description for accessibility */
            R.string.navigation_drawer_close  /* "close drawer" description for accessibility */
    )

用这个
mDrawerToggle = new ActionBarDrawerToggle(
            getActivity(),                    /* host Activity */
            mDrawerLayout,                    /* DrawerLayout object */
            R.drawable.ic_drawer,             /* nav drawer image to replace 'Up' caret */
            R.string.navigation_drawer_open,  /* "open drawer" description for accessibility */
            R.string.navigation_drawer_close  /* "close drawer" description for accessibility */
    )
mDrawerToggle = new ActionBarDrawerToggle(
            getActivity(),                    /* host Activity */
            mDrawerLayout,                    /* DrawerLayout object */
            R.string.navigation_drawer_open,  /* "open drawer" description for accessibility */
            R.string.navigation_drawer_close  /* "close drawer" description for accessibility */
    )