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
Post a Comment