android - Bottom Sheet not opening with the NavigationDrawer click -


i have 2 navigation drawers , bottom sheet in app. want expand bottom sheet click item navigation drawer. navigation drawers work fine.

updated xml....

<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     xmlns:tools="http://schemas.android.com/tools"     android:id="@+id/drawer_layout_widget"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:clickable="true"     android:focusableintouchmode="true">      <android.support.design.widget.coordinatorlayout xmlns:app="http://schemas.android.com/apk/res-auto"         android:layout_width="match_parent"         android:layout_height="match_parent">          <relativelayout             android:layout_width="match_parent"             android:layout_height="match_parent"             android:background="@color/bg_register"             app:layout_behavior="@string/appbar_scrolling_view_behavior"             tools:context="com.ceatkelanisrilanka.dushanmadushanka.ceat.ceatmainactivity"             tools:showin="@layout/activity_ceat_main">              <include                 android:id="@+id/app_bar"                 layout="@layout/app_toolbar_welcome_menu"></include>              <com.rey.material.widget.progressview                 android:id="@+id/pviewew"                 cpd_strokecolor="@android:color/holo_red_dark"                 cpd_strokesecondarycolor="@android:color/holo_blue_bright"                 cpd_strokesize="25dp"                 android:layout_width="50dp"                 android:layout_height="50dp"                 android:layout_aligntop="@+id/txtmonthsn"                 android:layout_centerhorizontal="true"                 app:pv_autostart="true"                 app:pv_circular="true"                 app:pv_progressmode="indeterminate"                 app:pv_progressstyle="@style/material.drawable.circularprogress" />              <textview                 android:id="@+id/txtmonth"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_alignleft="@+id/app_bar"                 android:layout_alignstart="@+id/app_bar"                 android:layout_below="@+id/app_bar"                 android:layout_margintop="2dp"                 android:paddingleft="10dp"                 android:text="month"                 android:textcolor="#ffffff"                 android:textsize="24sp" />              <textview                 android:id="@+id/txtmonthsn"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_alignparentend="true"                 android:layout_alignparentright="true"                 android:layout_aligntop="@+id/txtmonth"                 android:paddingright="10dp"                 android:text="monthsn"                 android:textcolor="#ffffff"                 android:textsize="24sp" />               <textview                 android:id="@+id/yeartextv"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_alignend="@+id/txtmonth"                 android:layout_alignright="@+id/txtmonth"                 android:layout_below="@+id/txtmonth"                 android:text="year"                 android:textappearance="?android:attr/textappearancesmall"                 android:textcolor="#ffffff" />              <relativelayout                 android:id="@+id/relativelayout2"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_above="@+id/relativelayout"                 android:layout_marginbottom="18dp">                  <com.github.lzyzsd.circleprogress.arcprogress                     android:id="@+id/arc_progress"                     android:layout_width="220dp"                     android:layout_height="220dp"                     android:layout_alignparentleft="true"                     android:layout_alignparentstart="true"                     android:layout_alignparenttop="true"                     android:layout_marginleft="20dp"                     android:layout_marginstart="20dp"                     android:padding="5dp" />              </relativelayout>              <!-- <com.github.lzyzsd.circleprogress.arcprogress                  android:id="@+id/arc_progress_two"                  android:layout_width="100dp"                  android:layout_height="100dp"                  android:layout_alignparentend="true"                  android:layout_alignparentright="true"                  android:layout_centervertical="true"                  android:layout_marginend="20dp"                  android:layout_marginright="20dp"                  android:padding="5dp"                  app:arc_bottom_text="precentage" />-->             <linearlayout                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_alignbottom="@+id/relativelayout2"                 android:layout_alignparentend="true"                 android:layout_alignparentright="true"                 android:layout_marginbottom="22dp"                 android:layout_marginend="20dp"                 android:layout_marginright="20dp"                 android:gravity="center"                 android:orientation="vertical">                  <com.hookedonplay.decoviewlib.decoview                     android:id="@+id/dynamicarcview"                     android:layout_width="100dp"                     android:layout_height="100dp"                     android:padding="5dp" />                  <textview                     android:id="@+id/pview"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:text="0 %"                     android:textcolor="#4b73c4"                     android:textsize="20sp" />                  <textview                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:text="precentage"                     android:textcolor="#4b73c4"                     android:textsize="15sp" />              </linearlayout>               <relativelayout                 android:id="@+id/relativelayout"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:layout_alignparentbottom="true"                 android:layout_alignparentleft="true"                 android:layout_alignparentstart="true"                 android:layout_marginbottom="23dp"                 android:paddingleft="5dp"                 android:paddingright="5dp">                  <textview                     android:id="@+id/txtmtar"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:layout_alignparentleft="true"                     android:layout_alignparentstart="true"                     android:layout_aligntop="@+id/txttarget"                     android:padding="5dp"                     android:text="monthly target"                     android:textappearance="?android:attr/textappearancemedium"                     android:textcolor="#ffffff" />                  <textview                     android:id="@+id/txtpre"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:layout_alignparentleft="true"                     android:layout_alignparentstart="true"                     android:layout_below="@+id/txtmach"                     android:layout_margintop="40dp"                     android:padding="5dp"                     android:text="percentage"                     android:textappearance="?android:attr/textappearancemedium"                     android:textcolor="#ffffff" />                  <textview                     android:id="@+id/txtmach"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:layout_alignparentleft="true"                     android:layout_alignparentstart="true"                     android:layout_margintop="80dp"                     android:padding="5dp"                     android:text="achievment"                     android:textappearance="?android:attr/textappearancemedium"                     android:textcolor="#ffffff" />                  <textview                     android:id="@+id/txttarget"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:layout_above="@+id/txtachievement"                     android:layout_alignleft="@+id/txtachievement"                     android:layout_alignstart="@+id/txtachievement"                     android:layout_marginbottom="35dp"                     android:padding="5dp"                     android:text="m"                     android:textappearance="?android:attr/textappearancemedium"                     android:textcolor="#ffffff" />                  <textview                     android:id="@+id/txtachievement"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:layout_above="@+id/txtpre"                     android:layout_centerhorizontal="true"                     android:padding="5dp"                     android:text="m"                     android:textappearance="?android:attr/textappearancemedium"                     android:textcolor="#ffffff" />                  <textview                     android:id="@+id/txtcollection"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:layout_alignbottom="@+id/txtpre"                     android:layout_alignleft="@+id/txtachievement"                     android:layout_alignstart="@+id/txtachievement"                     android:padding="5dp"                     android:text="m"                     android:textappearance="?android:attr/textappearancemedium"                     android:textcolor="#ffffff" />                  <button                     android:id="@+id/bvalue"                     style="?android:attr/buttonstylesmall"                     android:layout_width="120dp"                     android:layout_height="wrap_content"                     android:layout_alignbaseline="@+id/txtachievement"                     android:layout_alignbottom="@+id/txtachievement"                     android:layout_alignleft="@+id/bton"                     android:layout_alignstart="@+id/bton"                     android:text="value"                     android:textcolor="@color/border_gray" />                  <button                     android:id="@+id/bton"                     style="?android:attr/buttonstylesmall"                     android:layout_width="120dp"                     android:layout_height="wrap_content"                     android:layout_alignparentend="true"                     android:layout_alignparentright="true"                     android:layout_aligntop="@+id/txttarget"                     android:text="ton"                     android:textcolor="@color/border_gray" />                  <button                     android:id="@+id/bcollection"                     style="?android:attr/buttonstylesmall"                     android:layout_width="120dp"                     android:layout_height="wrap_content"                     android:layout_alignbottom="@+id/txtcollection"                     android:layout_alignleft="@+id/bvalue"                     android:layout_alignstart="@+id/bvalue"                     android:text="collection"                     android:textcolor="@color/border_gray" />              </relativelayout>          </relativelayout>           <include             android:id="@+id/bottom_sheet"             layout="@layout/bottom_sheet" />      </android.support.design.widget.coordinatorlayout>      <fragment         android:id="@+id/fragment_navigation_drawer"         android:name="com.ceatkelanisrilanka.dushanmadushanka.ceat.fragments.navigationdrawerfragment"         android:layout_width="@dimen/nav_drawer_width"         android:layout_height="match_parent"         android:layout_gravity="start"         app:layout="@layout/fragment_navigation_drawer"         tools:layout="@layout/fragment_navigation_drawer"></fragment>      <fragment         android:id="@+id/month_navigation_drawer"         android:name="com.ceatkelanisrilanka.dushanmadushanka.ceat.fragments.monthnavigationdrawerfragment"         android:layout_width="@dimen/month_nav_drawer_width"         android:layout_height="match_parent"         android:layout_gravity="end"         app:layout="@layout/month_navigation_drawer"         tools:layout="@layout/month_navigation_drawer"></fragment>  </android.support.v4.widget.drawerlayout> 

my monthnavigationdrawerfragment recyclerview click

recyclerview.addonitemtouchlistener(new recycletouchlistner(getactivity(), recyclerview, new clicklistener() {             @override             public void onclick(view view, int position) {                 switch (position) {                     case 0:                         welcomemenu.openbottomsheet();                         mdrawerlayout.closedrawers();                         break;                      case 1:                      ......                 }             }          }));         return vieww;     } 

my welcomemenu class

    public class welcomemenu extends appcompatactivity {          @override         protected void oncreate(bundle savedinstancestate) {             super.oncreate(savedinstancestate);             setcontentview(r.layout.welcome_menu);              vollysingleton = vollysingleton.getsinstance();             requestqueue = vollysingleton.getmrequestqueue();              typeface = typeface.createfromasset(getassets(), "helvr.ttf");             sntypeface = typeface.createfromasset(getassets(), "dl_paras.ttf");             welcomscreentypeface = typeface.createfromasset(getassets(), "productsans.ttf");              progressview = (progressview) findviewbyid(r.id.pviewew);              bottomsheet = findviewbyid(r.id.bottom_sheet);             bottomsheetbehavior = bottomsheetbehavior.from(bottomsheet);             initstate = bottomsheetbehavior.state_collapsed;              bottomsheet.post(new runnable() {                 @override                 public void run() {                     bottomsheetbehavior.setstate(initstate);                 }             });              toolbar = (toolbar) findviewbyid(r.id.app_bar);             setsupportactionbar(toolbar);             getsupportactionbar().setdisplayhomeasupenabled(true);             getsupportactionbar().settitle("achivements");              navigationdrawerfragment navigationdrawerfragment = (navigationdrawerfragment) getsupportfragmentmanager().findfragmentbyid(r.id.fragment_navigation_drawer);             navigationdrawerfragment.setup(r.id.fragment_navigation_drawer, (drawerlayout) findviewbyid(r.id.drawer_layout_widget), toolbar);              monthnavigationdrawerfragment monthnavigationdrawerfragment = (monthnavigationdrawerfragment) getsupportfragmentmanager().findfragmentbyid(r.id.month_navigation_drawer);             monthnavigationdrawerfragment.setup(r.id.month_navigation_drawer, (drawerlayout) findviewbyid(r.id.drawer_layout_widget), toolbar);              final calendar calendar = calendar.getinstance();             simpledateformat month_date = new simpledateformat("mmmm");             string month_name = month_date.format(calendar.gettime());             int year_name = calendar.get(calendar.year);             int monthno = calendar.get(calendar.month);              txttarget = (textview) findviewbyid(r.id.txttarget);             txtachievement = (textview) findviewbyid(r.id.txtachievement);             txtcollection = (textview) findviewbyid(r.id.txtcollection);             txtmonth = (textview) findviewbyid(r.id.txtmonth);             txtmonthsn = (textview) findviewbyid(r.id.txtmonthsn);             txtyear = (textview) findviewbyid(r.id.yeartextv);             txtm_tar = (textview) findviewbyid(r.id.txtmtar);             txtm_ach = (textview) findviewbyid(r.id.txtmach);             txtm_prec = (textview) findviewbyid(r.id.txtpre);             arcprogress = (arcprogress) findviewbyid(r.id.arc_progress);             pview = (textview) findviewbyid(r.id.pview);             //arcprogressprecentage = (arcprogress) findviewbyid(r.id.arc_progress_two);              df = new simpledateformat("yyyy-mm");             systemdate = df.format(new date());              arcview = (decoview) findviewbyid(r.id.dynamicarcview);              bton = (button) findviewbyid(r.id.bton);             bvalue = (button) findviewbyid(r.id.bvalue);             bcollection = (button) findviewbyid(r.id.bcollection);              txtmonth.settext(month_name);             txtmonth.settypeface(typeface);             txtm_prec.settypeface(welcomscreentypeface);             txtm_ach.settypeface(welcomscreentypeface);             txtm_tar.settypeface(welcomscreentypeface);             txtyear.settext(string.valueof(year_name));              db = new sqlitehandler(getapplicationcontext());              // session manager             session = new sessionmanager(getapplicationcontext());              if (!session.isloggedin()) {                 logoutuser();             } else {                 //pass button click operation                 getjsonrequest(bton, bcollection, bvalue, systemdate);             }          } public void openbottomsheet() {         bottomsheetbehavior = bottomsheetbehavior.from(bottomsheet);         bottomsheetbehavior.setstate(bottomsheetbehavior.state_expanded);      } } 

logcat

10:11:48.907 18943-18943/com.ceatkelanisrilanka.dushanmadushanka.ceat e/androidruntime: fatal exception: main                                                                                               process: com.ceatkelanisrilanka.dushanmadushanka.ceat, pid: 18943                                                                                               java.lang.nullpointerexception: attempt invoke virtual method 'void android.support.design.widget.bottomsheetbehavior.setstate(int)' on null object reference                                                                                                   @ com.ceatkelanisrilanka.dushanmadushanka.ceat.welcomemenu.openbottomsheet(welcomemenu.java:816)                                                                                                   @ com.ceatkelanisrilanka.dushanmadushanka.ceat.fragments.monthnavigationdrawerfragment$1.onclick(monthnavigationdrawerfragment.java:87)                                                                                                   @ com.ceatkelanisrilanka.dushanmadushanka.ceat.fragments.monthnavigationdrawerfragment$recycletouchlistner.onintercepttouchevent(monthnavigationdrawerfragment.java:239)                                                                                                   @ android.support.v7.widget.recyclerview.dispatchonitemtouchintercept(recyclerview.java:2206)                                                                                                   @ android.support.v7.widget.recyclerview.onintercepttouchevent(recyclerview.java:2252)                                                                                                   @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1960)                                                                                                   @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2405)                                                                                                   @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2106)                                                                                                   @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2405)                                                                                                   @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2106)                                                                                                   @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2405)                                                                                                   @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2106)                                                                                                   @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2405)                                                                                                   @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2106)                                                                                                   @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2405)                                                                                                   @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2106)                                                                                                   @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2405)                                                                                                   @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2106)                                                                                                   @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2405)                                                                                                   @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2106)                                                                                                   @ com.android.internal.policy.impl.phonewindow$decorview.superdispatchtouchevent(phonewindow.java:2369)                                                                                                   @ com.android.internal.policy.impl.phonewindow.superdispatchtouchevent(phonewindow.java:1719)                                                                                                   @ android.app.activity.dispatchtouchevent(activity.java:2742)                                                                                                   @ android.support.v7.view.windowcallbackwrapper.dispatchtouchevent(windowcallbackwrapper.java:60)                                                                                                   @ android.support.v7.view.windowcallbackwrapper.dispatchtouchevent(windowcallbackwrapper.java:60)                                                                                                   @ com.android.internal.policy.impl.phonewindow$decorview.dispatchtouchevent(phonewindow.java:2330)                                                                                                   @ android.view.view.dispatchpointerevent(view.java:8666)                                                                                                   @ android.view.viewrootimpl$viewpostimeinputstage.processpointerevent(viewrootimpl.java:4123)                                                                                                   @ android.view.viewrootimpl$viewpostimeinputstage.onprocess(viewrootimpl.java:3989)                                                                                                   @ android.view.viewrootimpl$inputstage.deliver(viewrootimpl.java:3544)                                                                                                   @ android.view.viewrootimpl$inputstage.ondelivertonext(viewrootimpl.java:3597)                                                                                                   @ android.view.viewrootimpl$inputstage.forward(viewrootimpl.java:3563)                                                                                                   @ android.view.viewrootimpl$asyncinputstage.forward(viewrootimpl.java:3680)                                                                                                   @ android.view.viewrootimpl$inputstage.apply(viewrootimpl.java:3571)                                                                                                   @ android.view.viewrootimpl$asyncinputstage.apply(viewrootimpl.java:3737)                                                                                                   @ android.view.viewrootimpl$inputstage.deliver(viewrootimpl.java:3544)                                                                                                   @ android.view.viewrootimpl$inputstage.ondelivertonext(viewrootimpl.java:3597)                                                                                                   @ android.view.viewrootimpl$inputstage.forward(viewrootimpl.java:3563)                                                                                                   @ android.view.viewrootimpl$inputstage.apply(viewrootimpl.java:3571)                                                                                                   @ android.view.viewrootimpl$inputstage.deliver(viewrootimpl.java:3544)                                                                                                   @ android.view.viewrootimpl.deliverinputevent(viewrootimpl.java:5807)                                                                                                   @ android.view.viewrootimpl.doprocessinputevents(viewrootimpl.java:5781)                                                                                                   @ android.view.viewrootimpl.enqueueinputevent(viewrootimpl.java:5752)                                                                                                   @ android.view.viewrootimpl$windowinputeventreceiver.oninputevent(viewrootimpl.java:5897)                                                                                                   @ android.view.inputeventreceiver.dispatchinputevent(inputeventreceiver.java:185)                                                                                                   @ android.os.messagequeue.nativepollonce(native method)                                                                                                 @ android.os.messagequeue.next(messagequeue.jav 04-20 10:16:48.999 18943-18943/com.ceatkelanisrilanka.dushanmadushanka.ceat i/process: sending signal. pid: 18943 sig: 9 

you can try first close navigation drawer , open bottom sheet try interchange lines of code


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -