android - How to avoid execute some piece of code in oncreateview while clicking back button in fragment -
i developing android application , trying implement drawer layout(slider menu) in project. let me explain project, have 1 recyclerview gridview items can able see our home screen. want display drawer layout on top grid items means recyclerview. display profile photo in drawer layout(slider menu) whenever application open after can swipe , usual can able see our grid items.
i did have 1 problem. able display drawer layout(slider menu) fine whenever application open after swipe if click 1 gridview item , enter page , if click back, time drawer layout(slider menu) showing should not show while clicking grid items.
have given recyclerview , drawer layout(slider menu) in same xml file reason whenever user click button, recyclerview displaying drawer layout(slider menu)
actually if use activity not face problem because in activity, if click button not call oncreate method call onrestart method reason oncreate not execute if click button also. in fragment oncreateview executing if click button problem because set of code should not execute in oncreateview if click button. please me solve problem.
this oncreateview code
@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view rootview = inflater.inflate(r.layout.test2, container, false); mdrawerlayout = (drawerlayout)rootview.findviewbyid(r.id.drawer_layout); mdrawerlist = (listview) rootview.findviewbyid(r.id.list_slidermenu); mdrawerlayout.opendrawer(gravity.left); navdraweritems = new arraylist<string>(); navdraweritems.add("first"); navdraweritems.add("second"); navdraweritems.add("third"); adapter = new navdrawerlistadapter(getactivity(),navdraweritems); mdrawerlist.setadapter(adapter); return rootview; }
this test2 layout xml code
<android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- framelayout display fragments --> <framelayout android:id="@+id/frame_container" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- grid view items --> <linearlayout android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:ads="http://schemas.android.com/apk/res-auto" android:cliptopadding="false" android:id="@+id/fade" android:orientation="vertical"> <linearlayout android:id="@+id/ll1" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="0.2" android:paddingright="5dp" android:paddingleft="5dp" android:orientation="vertical"> <android.support.v7.widget.recyclerview android:id="@+id/recycler_view" android:layout_width="match_parent" android:clickable="true" android:layout_height="match_parent"/> </linearlayout> </linearlayout> </framelayout> <!-- listview display slider menu --> <listview android:id="@+id/list_slidermenu" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="start" android:choicemode="singlechoice" android:divider="@null" android:listselector="@drawable/list_selector" android:background="@color/list_background"/> </android.support.v4.widget.drawerlayout>
atleast expecting line should not execute while clicking button mdrawerlayout.opendrawer(gravity.left);
Comments
Post a Comment