Navigation Drawer icon not showing (Sherlock actionbar)

前端 未结 11 1986
一向
一向 2021-02-04 03:41

Have the navigation Drawer working with the sherlock actionbar but i am having trouble getting the 3 line icon (like gmail) to show instead of the normal up button \"<\". He

相关标签:
11条回答
  • 2021-02-04 04:05

    Though I'm guessing by now you must have worked it out, just wanted to submit an answer:

    Change your code to the following:

    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawer,
            R.drawable.ic_drawer, R.string.menu_open, R.string.menu_close) {
        public void onDrawerClosed(View view) {
    
            super.onDrawerClosed(view);
        }
    
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    getSupportActionBar().setIcon(R.drawable.myIcon);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(true);
    

    Essentially, the ActionBar options that you are setting in code need to be set after the DrawerToggle has been completed, not before.

    0 讨论(0)
  • 2021-02-04 04:06

    Have you tried implementing the method:

        mDrawerToggle.syncState();
    

    This has worked for me in the past.

    0 讨论(0)
  • 2021-02-04 04:07

    May be this will work...

    in onCreateOptionMenu inflate your menu layout getSupportMenuInflater().inflate(R.menu.action_bar_menu, menu);

    0 讨论(0)
  • 2021-02-04 04:11

    What you can do is create a style like below:

     <style name="AppTheme" parent="Your Theme name">
            <item name="homeAsUpIndicator">@drawable/ic_drawer</item>
     </style>
    

    And in Android manifest apply this theme like:

    <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
    </application>
    

    This will solve the issue getting the 3 line icon for sure.

    0 讨论(0)
  • 2021-02-04 04:11

    Did you add the toggle to your drawer?

    mDrawerLayout.setDrawerListener(mDrawerToggle);
    
    0 讨论(0)
提交回复
热议问题