我有一个活动,使用滑动菜单库,我尝试创建 2 个滑动菜单。这是我试过的代码:
FragmentTransaction t = this.getSupportFragmentManager().beginTransaction();
menu = new SlidingMenu(this);
menu.setMode(SlidingMenu.RIGHT);
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE);
menu.setShadowWidthRes(R.dimen.shadow_width);
menu.setShadowDrawable(R.drawable.shadow);
menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
menu.setFadeDegree(0.35f);
menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
menu.setMenu(R.layout.tutorial_layout);
rightSlide = new HelpFragment();
t.replace(R.id.slidingList2, rightSlide);
t.commit();
menu.setSecondaryMenu(R.layout.log_history);
leftSlide = new LogHistory();
t.replace(R.id.loghistorycon, leftSlide);
t.commit();
现在我收到 ANR 错误,Logcat 说 FragmentTransaction t 已经提交。我查看了来自:github.com/jfeinstein10/SlidingMenu 的示例,它允许他执行 2 次提交:
setContentView(R.layout.content_frame);
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.content_frame, new SampleListFragment())
.commit();
getSlidingMenu().setSecondaryMenu(R.layout.menu_frame_two);
getSlidingMenu().setSecondaryShadowDrawable(R.drawable.shadowright);
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.menu_frame_two, new SampleListFragment())
.commit();
我究竟做错了什么?我只是看不出区别