Reputation: 23634
https://github.com/jfeinstein10/SlidingMenu
I am using this library, i would like to hide the sliding-menu when i open an new activity
, so that when i press back i don't want the sliding menu to appear.
@Override
public void onListItemClick(ListView lv, View v, int position, long id) {
switch (position) {
case 0:
Intent intent = new Intent("android.intent.action.Home");
getActivity().startActivity(intent);
break;
}
}
The above code is in my SherlockListFragment
class, i would like to hide the sliding-menu, once i start a new activity.
Upvotes: 1
Views: 4316
Reputation: 4868
@Override
public void onListItemClick(ListView lv, View v, int position, long id) {
switch (position) {
case 0:
Intent intent = new Intent("android.intent.action.Home");
getActivity().startActivity(intent);
// Toggle the sliding menu
((YourHostActivity) getActivity()).getSlidingMenu().toggle();
break;
}
}
In your activity that hosts the sliding menu:
public onCreate(...) {
// save the slidingmenu instance to a propery
mSlidingMenu = new SlidingMenu(this);
}
// create a getter
public SlidingMenu getSlidingMenu() {
return mSlidingMenu;
}
Upvotes: 3
Reputation: 2260
If you've extended SlidingActivity, then all you need is:-
toggle();
That should do it :-)
Upvotes: 12