java - Navigation Drawer is not opening on clicking menu icon -


navigation drawer not opening on clicking navigation icon(i.e 3 horizontal line on top left screen). on lollipop working, problem kitkat , jelly bean not working?

styles.xml

<resources>  <style name="apptheme" parent="theme.appcompat.light.darkactionbar">     <!-- customize theme here. -->     <item name="windowactionbar">false</item>     <item name="android:windowactionbaroverlay">true</item>     <item name="drawerarrowstyle">@style/drawerarrowstyle</item> </style>  <style name="drawerarrowstyle" parent="widget.appcompat.drawerarrowtoggle">     <item name="spinbars">true</item>     <item name="color">@android:color/white</item> </style> 

androidmanifes.xml

<application     android:name="com.volley_network_thread.appcontroller"     android:icon="@mipmap/ic_launcher"     android:allowbackup="true"     android:label="@string/app_name"     android:theme="@style/apptheme">      ......     ......     ......     ...... </application>  

toolbar.xml

<android.support.v7.widget.toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/app_theme_red_color" android:elevation="4dp" android:minheight="?attr/actionbarsize" android:title="@string/app_name"> 

activity_home.xml

<android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".mainactivity">   <framelayout     android:id="@+id/main"     android:layout_width="match_parent"     android:layout_height="match_parent">      <include layout="@layout/toolbar"></include> </framelayout>  <linearlayout     android:layout_width="300dp"     android:layout_height="fill_parent"     android:layout_gravity="start"     android:background="#fff"     android:orientation="vertical">      <relativelayout         android:layout_width="fill_parent"         android:layout_height="75dp"         android:layout_gravity="center"         android:background="@drawable/drawer_profile_bg">          <de.hdodenhof.circleimageview.circleimageview xmlns:app="http://schemas.android.com/apk/res-auto"             android:id="@+id/imageview_round"             android:layout_width="50dp"             android:layout_height="50dp"             android:layout_alignparentleft="true"             android:layout_centervertical="true"             android:layout_margintop="15dp"             android:src="@drawable/disp"             app:border_color="@color/gray_border"             app:border_width="2dp" />          <textview             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_alignparentright="true"             android:layout_centervertical="true"             android:text="ex : john mathew"             android:textcolor="@color/white"             android:textstyle="bold" />     </relativelayout>      <listview         android:id="@+id/drawer"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:background="#fff"         android:choicemode="singlechoice" />      <expandablelistview         android:id="@+id/lvexp"         android:layout_width="match_parent"         android:layout_height="fill_parent" />  </linearlayout> 

home.java

public class home extends actionbaractivity { toolbar toolbar; final string[] data = {"locate people", "account setting"}; drawerlayout drawer; actionbardrawertoggle mdrawertoggle;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_home);     initialize();     settoolbar(0);  }  private void initialize() {     toolbar = (toolbar) findviewbyid(r.id.toolbar);     setsupportactionbar(toolbar);     drawer = (drawerlayout) findviewbyid(r.id.drawer_layout);     getsupportactionbar().setdisplayhomeasupenabled(true);     getsupportactionbar().sethomebuttonenabled(true);      mdrawertoggle = new actionbardrawertoggle(this, drawer, toolbar, r.string.drawer_open, r.string.drawer_close) {          public void ondrawerclosed(view view) {             invalidateoptionsmenu();         }           public void ondraweropened(view drawerview) {             invalidateoptionsmenu();         }     }; // drawer toggle object made     drawer.setstatusbarbackgroundcolor(getresources().getcolor(r.color.app_theme_red_color));     drawer.setdrawerlistener(mdrawertoggle); // drawer listener set drawer toggle     mdrawertoggle.syncstate();               // set drawer toggle sync state }  @override public boolean onoptionsitemselected(menuitem item) {     // pass event actionbardrawertoggle, if returns     // true, has handled app icon touch event     if (mdrawertoggle.onoptionsitemselected(item)) {         return true;     }     // handle other action bar items...      return super.onoptionsitemselected(item); }  @override public void onconfigurationchanged(configuration newconfig) {     super.onconfigurationchanged(newconfig);     mdrawertoggle.onconfigurationchanged(newconfig); } @override protected void onpostcreate(bundle savedinstancestate) {     super.onpostcreate(savedinstancestate);     mdrawertoggle.syncstate(); } public void settoolbar(int position) {     if (position == 0) {         toolbar.settitle("establishemnt");         toolbar.settitletextcolor(getresources().getcolor(r.color.white));     } else if (position == 1) {         toolbar.settitle("settings");         toolbar.settitletextcolor(getresources().getcolor(r.color.white));     } } 

}

i face problem today.

i think it's drawerlayout @ root view, , set width , height = "match_parent".

in lolipop, tool bar popup , it's clickable. in kitkat or lower version, click on drawerlayout, not toolbar(the toolbar behind drawerlayout).

my solution set margintop = "?attr/actionbarsize" in drawerlayout.

hope it's helps thought it's has been long while : )


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -