2017-04-25 31 views
-1
public void setContentView(int layoutResID) 
    { 
     DrawerLayout fullView = (DrawerLayout) getLayoutInflater().inflate(R.layout.activity_base, null); 
     FrameLayout activityContainer = (FrameLayout) fullView.findViewById(R.id.activity_content); 
     getLayoutInflater().inflate(layoutResID, activityContainer, true); 
     super.setContentView(fullView); 
     Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
     setSupportActionBar(toolbar); 
     final ActionBar actionBar = getSupportActionBar(); 

     if (actionBar != null) 
     { 
      actionBar.setDisplayHomeAsUpEnabled(true); 
      mDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close) 
      { 

       public void onDrawerClosed(View view) 
       { 
        supportInvalidateOptionsMenu(); 
        //drawerOpened = false; 
       } 

       public void onDrawerOpened(View drawerView) 
       { 
        supportInvalidateOptionsMenu(); 
        //drawerOpened = true; 
       } 
      }; 
      mDrawerToggle.setDrawerIndicatorEnabled(true); 
      drawerLayout.setDrawerListener(mDrawerToggle); 
      mDrawerToggle.syncState(); 
     } 
    } 
} 

我想將導航抽屜圖標添加到此導航抽屜活動。現在我已經編輯的代碼,但現在還是錯誤的應用程序在啓動時停止無法將導航圖標添加到活動

+0

導航箭頭圖標或漢堡包圖標? –

+0

漢堡包圖標。因爲它的抽屜活動我需要將此活動擴展到所有其他活動 –

+0

你看看這個答案http://stackoverflow.com/q/28071763/7743702 –

回答

-1

也許你可以嘗試將其添加到佈局文件修改XML代碼,或按照本教程以獲取更多信息Android Sliding Menu

+0

我需要添加到此代碼 –

+0

所以如果你打開抽屜,你可以使圖標可見或去代碼 –