Control the Toolbar icon with NavigationDrawer

回眸只為那壹抹淺笑 提交于 2019-12-02 10:27:32

now I try to do a similiar navigation drawer as you... Basically respect me is that I had a diferent package for navigation drawer that I think so is different from your navigation drawer... My package is:

 //From android studio
 compile 'com.android.support:appcompat-v7:21.0.0'

I don't know if this can help you, but I follow this greatest tutorial and my navigation drawer work it's similar as you wish!

http://androideity.com/2013/12/16/android-navigation-drawer-parte-1/ http://androideity.com/2014/02/26/android-navigation-drawer-parte-2/

I wait that I help you! Good luck!

PD: If you have a problems with this tutorial or same advice me! :D

At first glance seems that you are setting new drawer listener whenever item is selected, precisely in this snippet:

 private class DrawerItemClickListener implements OnItemClickListener {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            //selectItem(position);
            final int thePos = position;
            mDrawer.setDrawerListener( new DrawerLayout.SimpleDrawerListener(){
                @Override
                public void onDrawerClosed(View drawerView){
                ....
                }
            });

            if(mDrawer.isDrawerOpen(GravityCompat.START))
                mDrawer.closeDrawer(mDrawerRelativeLayout);

        }
    }

This snippet replaces ActionBarDrawerToggle (which implements DrawerListener as well), so no calls are made to ActionBarDrawerToggle which controls the icon.

How can I adapt the icon behaviour so that it doesn't change from hamburger to arrow when I click over a drawer option?

Relating to your previous statements, this sound vague to me. Why you'd be preventing this default behaviour? You can prevent morphing by not calling super calls in DrawerListener's methods.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!