I am using android toolbar instead of action bar as you can see below inside code. I changed hamburger icon with what my clients want. But drawer menu does not open when I clicked on icon. Here is my code
@Override
protected void onCreate(Bundle savedInstanceState) {
toolbar=(Toolbar)findViewById(R.id.tool_bar);
toolbar.inflateMenu(R.menu.menu_event_list);
toolbar.setNavigationIcon(R.drawable.icon_menu);
toolbar.setOnMenuItemClickListener(menuClicked);
toolbar.setTitle(getResources().getString(R.string.app_name));
mRecyclerView=(RecyclerView)findViewById(R.id.RecyclerView);
mRecyclerView.setHasFixedSize(true);
mAdapter=new MenuAdapter(titles,icons,u.fullName,u.email,R.drawable.a,this);
mRecyclerView.setAdapter(mAdapter);
mLayoutManager=new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(mLayoutManager);
Drawer=(DrawerLayout)findViewById(R.id.DrawerLayout);
mDrawerToggle=new ActionBarDrawerToggle(this,Drawer,toolbar,R.string.app_name,R.string.app_name){
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
// code here will execute once the drawer is opened( As I dont want anything happened whe drawer is
// open I am not going to put anything here)
}
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
// Code here will execute once drawer is closed
}
};
mDrawerToggle.setHomeAsUpIndicator(R.drawable.icon_menu);
mDrawerToggle.setDrawerIndicatorEnabled(false);
Drawer.setDrawerListener(mDrawerToggle);
mDrawerToggle.syncState();
}
and xml for this
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/tool_bar"
layout="@layout/tool_bar"
/>
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/RecyclerView"
android:layout_width="280dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="#ffffff"
android:scrollbars="vertical">
</android.support.v7.widget.RecyclerView>