課程
/移動開發
/Android
/帶你實現別樣的Android側滑菜單
new?ActionBarDrawerToggle對象那個時,第三個參數代表的是什么
2017-03-23
源自:帶你實現別樣的Android側滑菜單 3-3
正在回答
ActionBarDrawerToggle ?是?DrawerLayout.DrawerListener實現。
和 NavigationDrawer 搭配使用,推薦用這個方法,符合Android design規范。
作用:
1.改變android.R.id.home返回圖標。
2.Drawer拉出、隱藏,帶有android.R.id.home動畫效果。
3.監聽Drawer拉出、隱藏;
做法,參照 NagatitionDrawer Demo。
重點在于:
/**
? * When using the ActionBarDrawerToggle, you must call it during
? * onPostCreate() and onConfigurationChanged()...
? */
?@Override
?protected void onPostCreate(Bundle savedInstanceState)
?{
? super.onPostCreate(savedInstanceState);
? // Sync the toggle state after onRestoreInstanceState has occurred.
? mDrawerToggle.syncState();
?}
?public void onConfigurationChanged(Configuration newConfig)
? super.onConfigurationChanged(newConfig);
? // Pass any configuration change to the drawer toggls
? mDrawerToggle.onConfigurationChanged(newConfig);
以及 mDrawerToggle 的初始構造方法
mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
? mDrawerLayout, /* DrawerLayout object */
??R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
? R.string.drawer_open, /* "open drawer" description for accessibility */
? R.string.drawer_close /* "close drawer" description for accessibility */
? )
最后不要忘了
mDrawerLayout.setDrawerListener(mDrawerToggle);
舉報
學會熟練使用側滑菜單之DrawerL,介紹常用菜單開源庫SlidingMenu
2 回答R.menu.main是什么操作啊
1 回答在哪下載代碼
1 回答這是錯誤了。。
1 回答課程下載的問題
1 回答并沒有實現title與菜單選中的城市同步?。?/p>
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2017-03-24
ActionBarDrawerToggle ?是?DrawerLayout.DrawerListener實現。
和 NavigationDrawer 搭配使用,推薦用這個方法,符合Android design規范。
作用:
1.改變android.R.id.home返回圖標。
2.Drawer拉出、隱藏,帶有android.R.id.home動畫效果。
3.監聽Drawer拉出、隱藏;
做法,參照 NagatitionDrawer Demo。
重點在于:
/**
? * When using the ActionBarDrawerToggle, you must call it during
? * onPostCreate() and onConfigurationChanged()...
? */
?@Override
?protected void onPostCreate(Bundle savedInstanceState)
?{
? super.onPostCreate(savedInstanceState);
? // Sync the toggle state after onRestoreInstanceState has occurred.
? mDrawerToggle.syncState();
?}
?@Override
?public void onConfigurationChanged(Configuration newConfig)
?{
? super.onConfigurationChanged(newConfig);
? // Pass any configuration change to the drawer toggls
? mDrawerToggle.onConfigurationChanged(newConfig);
?}
以及 mDrawerToggle 的初始構造方法
mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
? mDrawerLayout, /* DrawerLayout object */
??R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
? R.string.drawer_open, /* "open drawer" description for accessibility */
? R.string.drawer_close /* "close drawer" description for accessibility */
? )
最后不要忘了
mDrawerLayout.setDrawerListener(mDrawerToggle);