Navigation Drawer icon not showing (Sherlock actionbar)

前端 未结 11 2023
一向
一向 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 03:45

    @zudo1337 's method solved my problem.

    @Override
    protected void onPostCreate(Bundle savedInstanceState) {
        super.onPostCreate(savedInstanceState);
        // Sync the toggle state after onRestoreInstanceState has occurred.
        mDrawerToggle.syncState();
    }
    
    0 讨论(0)
  • 2021-02-04 03:51

    I have added this line before calling setDrawerListener.

    mDrawerLayout.post(new Runnable() {
    @Override public void run() {
     mDrawerToggle.syncState();
    }
    });
    

    Hope this will fix the issue in lower devices.

    0 讨论(0)
  • 2021-02-04 03:52

    You can look at this post first. There is one answer: "You can change back icon in Theme

    <item name="android:homeAsUpIndicator">@drawable/action_arrow</item>

    But I think you want implement Navigation Drawer, so read about it.

    0 讨论(0)
  • 2021-02-04 03:53

    This happen when you run your app in Android < 3, even Google apps suffer of this too.

    But there is a project than solve this: https://github.com/nicolasjafelle/SherlockNavigationDrawer

    0 讨论(0)
  • 2021-02-04 03:54

    This solution worked for me, and showed default navigation drawer icon in all version. Add SherlockNavigationDrawer library from here https://github.com/nicolasjafelle/SherlockNavigationDrawer to your project. And change your code as below :

    SherlockActionBarDrawerToggle mDrawerToggle = new SherlockActionBarDrawerToggle(this,mDrawerLayout,
       R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) {
       public void onDrawerClosed(View view) {
           super.onDrawerClosed(view);
       }
       public void onDrawerOpened(View drawerView) {
           super.onDrawerOpened(drawerView);
       }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    getSupportActionBar().setIcon(R.drawable.ic_launcher);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(true);
    
    0 讨论(0)
  • 2021-02-04 03:59

    I put this in and it works.

        @Override
    protected void onPostCreate(Bundle savedInstanceState) {
        super.onPostCreate(savedInstanceState);
        // Sync the toggle state after onRestoreInstanceState has occurred.
        mDrawerToggle.syncState();
    }
    
    0 讨论(0)
提交回复
热议问题