java - Android DrawerLayout not Closing -
java - Android DrawerLayout not Closing -
i having problem getting android drawerlayout close.
in implementation using linearlayout rather listview. list view implementation 1 commonly found in of tutorials , discussed on site.
in implementation want utilize same drawerlayout on activities of application. reason of xml layout files utilize include cutting downwards amount of code 1 needs store.
the functionality of drawer , it's buttons want them be. draw slides open on swipe, closes on swipe , buttons respond appropriate functionality. however, cannot drawer close programmatically calling of following. has no effect.
drawerlayout.closedrawers(); drawerlayout.closedrawer(gravity_start); drawerlayout.closedrawer(drawerlinearlayout);
i tried few variants on calling whole drawlayout object veiw no avail, tried different gravity options. here got run time errors complaining illegal states. why closing draw programmatically such hard thing do? why closedrawers not work? how can close , cleanly?
below code 1 such activity's layout.
<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"> <!-- main content view, view below consumes entire space available using match_parent in both dimensions. --> <framelayout android:id="@+id/content_frame" android:background="#000000" android:layout_width="match_parent" android:layout_height="match_parent" /> <include android:id="@+id/left_draw" android:layout_width="240dp" android:layout_height="match_parent" layout="@layout/options_draw" android:layout_gravity="start"/> </android.support.v4.widget.drawerlayout>
the include refers layout below. defines layout of 6 buttons plus 2 radio buttons.
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_linear_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/splash_screen1" android:orientation="vertical" android:weightsum="8" > <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="2" android:background="@color/t_blue" android:orientation="horizontal" android:weightsum="10" > <button android:id="@+id/cmd_map" android:layout_width="0dp" android:layout_height="match_parent" android:layout_margin="2dp" android:layout_weight="5" android:background="@drawable/gradient_button1" android:onclick="option1selected" android:text="@string/drawer_cmd_map" /> <button android:id="@+id/cmd_locdata" android:layout_width="0dp" android:layout_height="match_parent" android:layout_margin="2dp" android:layout_weight="5" android:background="@drawable/gradient_button1" android:onclick="option2selected" android:text="@string/drawer_cmd_locdata" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="2" android:background="@color/t_blue" android:orientation="horizontal" android:weightsum="10" > <button android:id="@+id/cmd_hurlist" android:layout_width="0dp" android:layout_height="match_parent" android:layout_margin="2dp" android:layout_weight="5" android:background="@drawable/gradient_button1" android:onclick="option3selected" android:text="@string/drawer_cmd_hurlisrt" /> <button android:id="@+id/cmd_settings" android:layout_width="0dp" android:layout_height="match_parent" android:layout_margin="2dp" android:layout_weight="5" android:background="@drawable/gradient_button1" android:onclick="option4selected" android:text="@string/drawer_cmd_legend" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="2dp" android:layout_weight="2" android:background="@drawable/bk_gradient4" android:orientation="vertical" android:weightsum="10" > <textview android:id="@+id/textview1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_marginbottom="10px" android:gravity="center" android:paddingtop="5dp" android:text="@string/drawer_txt_datapoints" android:textappearance="?android:attr/textappearancemedium" /> <radiogroup android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_margin="10dp" android:id="@+id/radio_group"> <radiobutton android:id="@+id/first_radio_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:paddingleft="40dip" android:text="@string/drawer_rb_data_option1"/> <radiobutton android:id="@+id/second_radio_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="false" android:paddingleft="40dip" android:text="@string/drawer_rb_data_option2" /> </radiogroup> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="2" android:background="@color/t_blue" android:orientation="horizontal" android:weightsum="10" > <button android:id="@+id/cmd_legend" android:layout_width="0dp" android:layout_height="match_parent" android:layout_margin="2dp" android:layout_weight="5" android:background="@drawable/gradient_button1" android:onclick="option5selected" android:text="@string/drawer_cmd_settings" /> <button android:id="@+id/cmd_about" android:layout_width="0dp" android:layout_height="match_parent" android:layout_margin="2dp" android:layout_weight="5" android:background="@drawable/gradient_button1" android:onclick="option6selected" android:text="@string/drawer_cmd_about" /> </linearlayout> </linearlayout>
i aware there topic on problem (here), relates drawlayout listview. creating drawerlayout linearlayout question different.
java android
Comments
Post a Comment