https://github.com/jfeinstein10/SlidingMenu
我æ£åœ¨ä½¿ç”¨è¿™ä¸ªåº“,我想在打开一个新的activity
æ—¶éšè—滑动èœå•ï¼Œè¿™æ ·å½“我按下时我ä¸å¸Œæœ›å‡ºçŽ°æ»‘动èœå•ã€‚
@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;
}
}
上é¢çš„代ç 在我的SherlockListFragment
课程ä¸ï¼Œæˆ‘想在开始新活动时éšè—滑动èœå•ã€‚
ç”案 0 :(得分:12)
如果您已ç»æ‰©å±•äº†SlidingActivity,那么您åªéœ€è¦ï¼š -
toggle();
åº”è¯¥è¿™æ ·åšï¼š - )
ç”案 1 :(得分:3)
@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;
}
}
在托管滑动èœå•çš„活动ä¸ï¼š
public onCreate(...) {
// save the slidingmenu instance to a propery
mSlidingMenu = new SlidingMenu(this);
}
// create a getter
public SlidingMenu getSlidingMenu() {
return mSlidingMenu;
}