2

我对 android 完全陌生,我被赋予了一项任务,即通过单击放置在角落两侧的按钮来滑动菜单。与 Facebook 应用程序非常相似。我尝试使用 SherlockAction 栏库和 Slidingmenu 库,但我不太了解它的功能。请帮帮我。

提前致谢

4

1 回答 1

0

如果您需要将 ABS 与 SlidingMenu 一起使用,首先进入您计划使用的 SlidingActivity,使它们扩展 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 的“后面”部分。

于 2013-11-09T13:40:19.857 回答