Android : How can i create a listview menu with a drawer navigation?

on Sunday, August 10, 2014


i'm trying to create an mobile application with listview as a main menu then with navigation drawer. but everytime i use the setDrawerListener it gives me an error in emulator "Unfortunate, myapps has stop". and even extending my class to ActionBarActivity produce the same error. i think it is on my xml file but can't figure it out. please help guys. thanks you in advance.


here's my xml code.



<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawerLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<!-- main Content View -->
<!-- here im trying to create the menu tab with a listview inside of every tab -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >

<TabHost
android:id="@+id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#fdf34e">
</TabWidget>

<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<LinearLayout
android:id="@+id/tab1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Announcements will be visible here..."
android:textSize="20sp"
android:layout_gravity="center"
android:layout_margin="10dp" />

</LinearLayout>

<LinearLayout
android:id="@+id/tab2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<ListView
android:id="@+id/lvMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>

</LinearLayout>

<LinearLayout
android:id="@+id/tab3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<ListView
android:id="@+id/lvAccount"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>

</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>

<!-- here starting to construct the Navigation Drawer -->
<FrameLayout
android:id="@+id/content"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</FrameLayout>

<!-- actual Navigation Drawer -->
<ListView
android:id="@+id/lvdrawerlist"
android:background="#ebebe8"
android:layout_width="240dp"
android:layout_height="fill_parent"
android:layout_gravity="left" >
</ListView>

</android.support.v4.widget.DrawerLayout>

0 comments:

Post a Comment