android - ImageView onClick opens Sliding Menu -


so have app uses buttons go different activities. below them, have imagebuttons want use 2 of them open 2 different sliding menus. have read, sliding menus here show way of using sliding menu.

so code activity that:

public class choosecategory extends activity {     @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_choose_category); } 

and xml code is:

<relativelayout     xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/drawer_layout"     android:layout_width="match_parent"     android:layout_height="match_parent">       <linearlayout          android:layout_width="match_parent"          android:layout_height="wrap_content"          android:orientation="vertical" >      <linearlayout         android:layout_width="match_parent"     android:layout_height="wrap_content"     android:layout_weight="1"     android:background="#be2625"     android:orientation="vertical">      <button     android:id="@+id/fancy"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:text="@string/fancy"     android:textcolor="#ffffff"     android:background="@drawable/button4"     />        <button      android:id="@+id/chipchop"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:text="@string/chipchop"     android:textcolor="#ffffff"     android:background="@drawable/button4"     />        <button      android:id="@+id/pizza"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:text="@string/pizza"     android:textcolor="#ffffff"     android:background="@drawable/button4"     />        <button      android:id="@+id/asian"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:text="@string/asian"     android:textcolor="#ffffff"     android:background="@drawable/button4"     />        <button      android:id="@+id/indian"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:text="@string/indian"     android:textcolor="#ffffff"     android:background="@drawable/button4"     />        <button      android:id="@+id/kebab"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:text="@string/kebab"     android:textcolor="#ffffff"     android:background="@drawable/button4"     />        <button      android:id="@+id/other"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:text="@string/other"     android:textcolor="#ffffff"     android:background="@drawable/button4"     />      </linearlayout>       <linearlayout         android:id="@+id/ll_menu"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:padding="5dp"         android:gravity="bottom"         android:background="#be2620" >                    <!-- contentdescription tags added remove related warnings -->              <imagebutton                 android:id="@+id/btn_home"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_weight="0.25"                 android:background="@null"                 android:src="@drawable/ic_launcher"                  />              <imagebutton                 android:id="@+id/btn_book"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_weight="0.25"                 android:background="@null"                 android:src="@drawable/ic_launcher"                   />              <imagebutton                 android:id="@+id/btn_find_us"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_weight="0.25"                 android:background="@null"                 android:src="@drawable/ic_launcher"                   />              <imagebutton                 android:id="@+id/btn_menu"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_weight="0.25"                 android:background="@null"                 android:src="@drawable/ic_launcher"                   />       </linearlayout>      </linearlayout>     <!-- 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:dividerheight="1dp"                android:background="#ffffff"/>   </relativelayouts> 

any help, on how use code or code in order click on imagebutton , open sliding menu?

i did project.

call

getslidingmenu().toggle(); //to open left side menu 

and call

getslidingmenu().showsecondarymenu(); //to open right side menu 

also if want open menus after clicking icons sherlockactionbar

modify onoptionsitemselected method in baseactivity following

@override public boolean onoptionsitemselected(menuitem item) {     switch (item.getitemid()) {     case android.r.id.home:         toggle();         return true;     case r.id.github:         //util.gotogithub(this);         showsecondarymenu();         return true;     }     return super.onoptionsitemselected(item); } 

update:

extend baseactivity class

public class choosecategory extends baseactivity {     @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_choose_category);          imagebutton button1 = (imagebutton) findviewbyid(r.id.button1);         button1.setonclicklistener(new view.onclicklistener() {             public void onclick(view v) {                 getslidingmenu().toggle(); // open left side menu             }         }          imagebutton button2 = (imagebutton) findviewbyid(r.id.button2);         button2.setonclicklistener(new view.onclicklistener() {             public void onclick(view v) {                 getslidingmenu().showsecondarymenu(); // open right side menu             }         }     }); } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -