2

我正在使用jfeinstein10库和示例项目。我想在左侧滑动菜单中显示一些菜单选项,并在右侧滑动菜单中显示一些其他选项菜单。但我不能那样做。这是代码:包com.slidingmenu.example;

public class LeftAndRightActivity extends BaseActivity {

    public LeftAndRightActivity() {
        super(R.string.left_and_right);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getSlidingMenu().setMode(SlidingMenu.LEFT_RIGHT);
        getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

        setContentView(R.layout.content_frame);
        getSupportFragmentManager()
        .beginTransaction()
        .replace(R.id.content_frame, new SampleFragment())
        .commit();

        getSlidingMenu().setSecondaryMenu(R.layout.menu_frame_two);
        getSlidingMenu().setSecondaryShadowDrawable(R.drawable.shadowright);
        getSupportFragmentManager()
        .beginTransaction()
        .replace(R.id.menu_frame_two, new SampleFragment())
        .commit();
    }

}

这是我在 onCreate 中设置的内容:

getSlidingMenu().setMode(SlidingMenu.LEFT_RIGHT);
        getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

        setContentView(R.layout.content_frame);

        getSupportFragmentManager()
        .beginTransaction()
        .replace(R.id.content_frame, new SampleListFragment())
        .commit();


        getSlidingMenu().setMenu(R.layout.menu_frame_two);
        getSlidingMenu().setShadowDrawable(R.drawable.shadowright);
        getSupportFragmentManager()
        .beginTransaction()
        .replace(R.id.menu_frame_two, new SampleListFragment2())
        .commit();

        getSlidingMenu().setSecondaryMenu(R.layout.menu_frame_two);
        getSlidingMenu().setSecondaryShadowDrawable(R.drawable.shadowright);
        getSupportFragmentManager()
        .beginTransaction()
        .replace(R.id.menu_frame_two, new SampleListFragment2())
        .commit();

每当我使用它时,我的程序都会崩溃。这是我的 logcat:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.slidingmenu.example/com.slidingmenu.example.LeftAndRightActivity}: java.lang.IllegalArgumentException: No view found for id 0x7f05003c for fragment Fragment{41260b30 #0 id=0x7f05003c}
4

0 回答 0