i use this library works fine, dont know how create if click item 1 in menu output text, if click item 2 in menu output text 2...
here code :
@override public boolean onoptionsitemselected(menuitem item) { log.e("click", "click"); switch (item.getitemid()) { case android.r.id.home: menu.toggle(true); return true; case r.id.textview1: log.e("textview1", "textview1"); break; case r.id.textview2: log.e("textview2", "textview2"); break; case r.id.textview3: log.e("textview3", "textview3"); break; default: break; } return super.onoptionsitemselected(item); }
upd
menu_flame.xml
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="500dp" android:layout_height="wrap_content" android:orientation="vertical" android:background="@color/back"> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginbottom="10dp" > <imageview android:id="@+id/imageview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/abc_ratingbar_full_material" /> <textview android:id="@+id/textview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/menu_1" android:layout_gravity="center_vertical" android:textappearance="?android:attr/textappearancelarge" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginbottom="10dp" > <imageview android:id="@+id/imageview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/abc_ratingbar_full_material" /> <textview android:id="@+id/textview2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/menu_2" android:layout_gravity="center_vertical" android:textappearance="?android:attr/textappearancelarge" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginbottom="10dp" > <imageview android:id="@+id/imageview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/abc_ratingbar_full_material" /> <textview android:id="@+id/textview3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/menu_3" android:layout_gravity="center_vertical" android:textappearance="?android:attr/textappearancelarge" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginbottom="10dp" > <imageview android:id="@+id/imageview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/abc_ratingbar_full_material" /> <textview android:id="@+id/textview4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/menu_4" android:layout_gravity="center_vertical" android:textappearance="?android:attr/textappearancelarge" /> </linearlayout> </linearlayout>
activitymain.xml
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context="com.example.testdesigne.mainactivity" > <listview android:id="@+id/list" android:layout_width="fill_parent" android:layout_height="wrap_content" android:dividerheight="1dp" /> </relativelayout>
main:
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); menu = new slidingmenu(this); menu.setmode(slidingmenu.left); menu.settouchmodebehind(slidingmenu.touchmode_fullscreen); menu.setshadowdrawable(r.drawable.slidemenu_shadowgradient); menu.setshadowwidth(15); menu.setfadedegree(0.0f); menu.attachtoactivity(this, slidingmenu.sliding_window); menu.setbehindwidth(300); menu.setmenu(r.drawable.menu_frame); getsupportactionbar().setdisplayshowcustomenabled(true); getsupportactionbar().setdisplayhomeasupenabled(true); } @override public boolean onoptionsitemselected(menuitem item) { log.e("click", "click"); switch (item.getitemid()) { case android.r.id.home: log.e("item", integer.tostring(item.getitemid())); menu.toggle(true); return true; case r.id.textview1: log.e("textview1", "textview1"); break; case r.id.textview2: log.e("textview2", "textview2"); break; case r.id.textview3: log.e("textview3", "textview3"); break; } return super.onoptionsitemselected(item); }