android - How to navigate to Activity from Sliding panel when the back button is pressed -


i have fragment activity sliding panel in it. implemented following exit app when user presses button.

@override     public void onbackpressed() {         //this close , exit app         intent intent = new intent(intent.action_main);         intent.addcategory(intent.category_home);         intent.setflags(intent.flag_activity_clear_top);//***change here***         startactivity(intent);         finish();         system.exit(0);     } 

however, stay in same activity if the user on sliding panel , wants navigate activity. right if user presses button when sliding panel displayed, closes app. how accomplish that?

hope using slidingpanellayout

mslidingpanellayout = (slidingpanelayout) findviewbyid(r.id.label); 

then

public void onbackpressed() {     if(mslidingpanellayout.isopen())     {         mslidingpanellayout.closepane();     }     else      {         //closeactivity();     } } 

you can use panelslidelistener

    mslidingpanellayout.setpanelslidelistener(new slidingpanelayout.panelslidelistener() {         @override         public void onpanelslide(view panel, float slideoffset) {          }          @override         public void onpanelopened(view panel) {          }          @override         public void onpanelclosed(view panel) {          }     }); 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -