空白SlidingMenu与片段活动和ActionBarSherlock

时间:2013-08-22 14:17:57

标签: android-fragments actionbarsherlock slidingmenu

我正在使用Jeremy Feinstein的SlidingMenu进行片段活动和actionbarsherlock。我活动中的滑动菜单是空白的。

我的滑动菜单的代码来自Michenux的教程12

我错过了什么?任何反馈都将非常感谢!!

Dashboard.java

public class Dashboard extends BaseFragmentActivity {
    DashboardFragment dashFragment;
    private Bundle extras;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getIntent() != null) {
            extras = getIntent().getExtras();
        }

        getSupportActionBar().setIcon(R.drawable.img_activity_logo);
        getSupportActionBar().setDisplayShowTitleEnabled(true);
        getSupportActionBar().setTitle(R.string.dashboardtitle);

        if (arg0 == null) {
            dashFragment = new DashboardFragment();
        if (extras != null) {
            dashFragment.setArguments(extras);
        }

        FragmentManager fragmentManager = this.getSupportFragmentManager();
            fragmentManager.beginTransaction().add(android.R.id.content, dashFragment, "Dashboard").commit();
        }
    }
}

DashboardFragment.java - 我正在创建滑动菜单:

public class DashboardFragment extends BaseFragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        View view = inflater.inflate(R.layout.dashboard, null);
        return view;
    }

    @Override
    public void onResume() {
        super.onResume();

        slidingMenu = new SlidingMenu(getActivity());
        slidingMenu.setMode(SlidingMenu.RIGHT);
        slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
        slidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
        slidingMenu.setFadeDegree(0.35f);
        slidingMenu.attachToActivity(getActivity(), SlidingMenu.SLIDING_WINDOW);
        slidingMenu.setMenu(R.layout.slidingmenu);  
    }

}

BaseFragmentActivity.java

public class BaseFragmentActivity extends SherlockFragmentActivity {
    ...
}

BaseFragment.java

public class BaseFragment extends SherlockFragment {
    ...
}

0 个答案:

没有答案