I have a navigation drawer made using drawer layout and adapter. I want to add a logout button at the bottom of the side menu. I went through SO, but couldn't solve. The main xml file has a list view in a drawer layout.
<?xml version="1.0" encoding="utf-8"?>
<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">
<LinearLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="5"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.5"></LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:layout_gravity="center"
android:orientation="vertical">
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/buttonbackground"
android:text="PHOTOS"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
android:textColor="@color/white" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:background="@drawable/buttonbackground"
android:text="VIDEOS"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
android:textColor="@color/white" />
<Button
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:background="@drawable/buttonbackground"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
android:text="HISTORY"
android:textColor="@color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.5"></LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/navList"
android:layout_width="320dp"
android:layout_height="match_parent"
android:layout_above="@+id/logout"
android:layout_gravity="left|start"
android:background="#ffeeeeee"></ListView>
<Button
android:id="@+id/logout"
android:layout_width="320dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="LogOut" />
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
<android.support.v4.widget.DrawerLayout/>
And the list is being inflated in the java code.
private void addDrawerItems() {
String items[]={"Home","Video","Camera","History","Version"};
mAdapter=new ArrayAdapter<>(this,R.layout.listview_drawer_item_row,items);
mDrawerList.setAdapter(mAdapter);
}
How do I add a button at the bottom of the menu?