簡體   English   中英

默認的Android Studio導航抽屜活動模板不顯示漢堡圖標,僅顯示箭頭圖標

[英]Default Android Studio Navigation Drawer Activity Template does not show Hamburger Icon, only arrow icon

這個人基本上遇到了我遇到的同樣的問題 ,但是,提供的解決方案沒有幫助,也不適用於我,因為我的代碼實際上是調用mDrawerToggle.sycnState()(在延遲的Runnable中)。

我也嘗試將它添加到我的片段中的onActivityCreated,它似乎沒有做任何事情。 不知道究竟是什么syncState做什么,我無法判斷它是否正在同步打開狀態(模板代碼默認發生),然后在手動關閉抽屜時它永遠不會再次同步。

我發布了代碼但您可以通過在Android Studio(1.2.2)中創建一個新項目,選擇導航抽屜活動,然后只是運行項目來測試這一點 - 無需進行任何更改。 你會看到唯一的圖標是< - 箭頭。 我甚至設置了斷點來檢查ActionBarDrawerToggle對象,該對象實際上在其內存中有漢堡圖標,用於繪制圖標,讓我更加驚慌!

我在這里結束了我的智慧。

我剛剛想出了一個解決方案,以防其他人遇到這個問題:

更改片段頂部的導入

import android.support.v4.app.ActionBarDrawerToggle;

import android.support.v7.app.ActionBarDrawerToggle;

然后更改setUp中的代碼

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 */
    )

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM