android - Return back when clicking an item on a SlidingMenu -


how can close open fragment , return main activity?

public class mainactivity extends slidingfragmentactivity { public slidingmenu sm;   @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);      getwindow().setflags(windowmanager.layoutparams.flag_fullscreen,             windowmanager.layoutparams.flag_fullscreen);      // main layout     setcontentview(r.layout.activity_main);     setbehindcontentview(r.layout.menu_frame);       // slidingmenu      sm = getslidingmenu();     sm.setfadedegree(0.35f);     sm.settouchmodeabove(slidingmenu.touchmode_fullscreen);     sm.setbehindoffset(120);     sm.setmode(slidingmenu.left_right);      // left menu     getsupportfragmentmanager().begintransaction()             .replace(r.id.menu_frame, new leftmenufragment()).commit();      // right menu     getslidingmenu().setsecondarymenu(r.layout.menu_frame_second);     getsupportfragmentmanager().begintransaction()             .replace(r.id.menu_frame_two, new rightmenufragment()).commit();           }    public class leftmenufragment extends fragment{  imageview img;  @override public view oncreateview(layoutinflater inflater, viewgroup container,         bundle savedinstancestate) {     view view = inflater.inflate(r.layout.fragment_left_menu, container,             false);     this.inflater = inflater;   img = (imageview) view.findviewbyid(r.id.test);  img.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {             //return main activity         }     });   }  return view; } 

is possible create vertical sliding?

if want close sliding menu do

if(sm.ismenushowing()){     sm.toggle(); } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -