我是Android的新手,我已经完成了点击角落两侧按钮的滑动菜单的任务。非常类似于Facebook应用程序。我尝试使用SherlockAction条形图库和Slidingmenu库,但我不太了解它的功能。请帮帮我。
提前致谢
答案 0 :(得分:0)
如果您需要将ABS与SlidingMenu一起使用,请首先进入您计划使用的SlidingActivities,使它们延伸Sherlock __ Activity而不是_ _Activity。
然后试试:
public class FragmentsHolderActivity extends SlidingFragmentActivity {
public static boolean isChangeCategoryAllow = true;
public static ImageLoader imageLoader = ImageLoader.getInstance();
public MenuItem mRefreshMenuItem;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
final SlidingMenu sm = getSlidingMenu();
sm.setFadeEnabled(false);
sm.setShadowWidthRes(R.dimen.shadow_width);
sm.setShadowDrawable(R.drawable.shadow);
sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
// set the Above View
setContentView(R.layout.content_frame);
//add if you need dinamically customize your fragment as your liking.
/*getSupportFragmentManager()
.beginTransaction()
.replace(R.id.content_frame, new CategoryImagesListFragment())
.commit();*/
// set the Behind View
setBehindContentView(R.layout.menu_frame);
//add if you need dinamically customize the SlidingMenu as your liking.
/*getSupportFragmentManager()
.beginTransaction()
.replace(R.id.menu_frame, new CategoryFragment())
.commit(); */
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle presses on the action bar items
switch (item.getItemId()) {
case android.R.id.home:
toggle();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
setBehindContentView 会将视图放在SlidingMenu的“后面”部分。