2014-03-13 21 views
7

我使用ActionBarDrawerToggle類將DrawerLayout和框架ActionBar的功能綁定在一起,以實現對導航抽屜的推薦設計。在ActionBarDrawerToggle中使用syncState()

說什麼Android開發者網站

Call syncState() from your Activity's onPostCreate to synchronize the indicator with the state of the linked DrawerLayout after onRestoreInstanceState has occurred. 

但我沒有得到什麼syncState()方法實際上呢?

請儘可能簡單地解釋它。

回答

4

DrawerLayout指標是小圖標ActionBar家圖標的左側(見圖)

ActionBarDrawerToggle.syncState被稱爲正常偏移基礎上,DrawerLayout這是否指示燈打開或實例狀態後關閉DrawerLayout已被恢復。

DrawerLayout indicator

4

呼叫syncState()從活動的onPostCreate設置基礎上的指示燈的狀態drawerlayout是否打開或閉合狀態,一旦活動已經恢復了與onRestoreInstanceState。

protected void onPostCreate(Bundle savedInstanceState) { 
     // TODO Display the navigation drawer icon on action bar when there state has changed 
     super.onPostCreate(savedInstanceState); 
     drawerListener.syncState(); 
    } 
0

它是從活動的​​稱爲發生onRestoreInstanceState後用鏈接DrawerLayout的狀態指示燈同步。

例如

protected void onPostCreate(Bundle savedInstanceState) 
{ 
    super.onPostCreate(savedInstanceState); 
    this.navDrawerToggle.syncState() 

} 
相關問題