Android 滑动菜单两侧有两个单独的列表
我在一个两边都有滑动菜单的应用程序中工作。我试着使用导航抽屉,但无法像在facebook上那样通过将主屏幕推到右侧来显示菜单。所以我使用了滑动菜单库。这是很好的工作,但我面临的问题是,相同的名单是在双方。请帮助我如何为左菜单和右菜单带来单独的列表 这是我的密码Android 滑动菜单两侧有两个单独的列表,android,listview,slider,slidetoggle,swipe-gesture,Android,Listview,Slider,Slidetoggle,Swipe Gesture,我在一个两边都有滑动菜单的应用程序中工作。我试着使用导航抽屉,但无法像在facebook上那样通过将主屏幕推到右侧来显示菜单。所以我使用了滑动菜单库。这是很好的工作,但我面临的问题是,相同的名单是在双方。请帮助我如何为左菜单和右菜单带来单独的列表 这是我的密码 sm = getSlidingMenu(); sm.setMode(SlidingMenu.LEFT_RIGHT); sm.setSecondaryMenu(R.layout.menu_frame_two); getSupportFrag
sm = getSlidingMenu();
sm.setMode(SlidingMenu.LEFT_RIGHT);
sm.setSecondaryMenu(R.layout.menu_frame_two);
getSupportFragmentManager()
.beginTransaction().replace(R.id.menu_frame_two, new SampleListFragment())
.commit();
在SampleListFragment类中,为左菜单创建了动态列表,在SampleListRight类中为右菜单创建了动态列表。我无法在代码中引入SampleListRight类。
请帮帮我
sm = getSlidingMenu();
// set slidder mode
sm.setMode(SlidingMenu.LEFT_RIGHT);
sm.setShadowWidthRes(R.dimen.shadow_width);
sm.setShadowDrawable(R.drawable.shadow);
sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
sm.setFadeDegree(0.35f);
sm.setTouchModeAbove(SlidingMenu.LEFT);
//set right slider mode
sm.setSecondaryMenu(R.layout.right_main);
// Setting the Behind Left View
setBehindContentView(R.layout.left_main);
if (savedInstanceState == null) {
FragmentTransaction t = this.getSupportFragmentManager()
.beginTransaction();
leftFragment = new MenuFragment();
t.replace(R.id.left_container, leftFragment, MenuFragment.TAG);
t.commit();
} else {
leftFragment = (ListFragment) this.getSupportFragmentManager()
.findFragmentByTag(MenuFragment.TAG);
}
// Setting the Behind right View
if (savedInstanceState == null) {
FragmentTransaction t = this.getSupportFragmentManager()
.beginTransaction();
rightFragment = new RightFragment();
t.replace(R.id.right_container, rightFragment, RightFragment.TAG);
t.commit();
} else {
rightFragment = (ListFragment) this.getSupportFragmentManager()
.findFragmentByTag(RightFragment.TAG);
}
将此布局用于左侧和右侧抽屉,并在framelayout中替换片段,无论您想要什么
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/main_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
</RelativeLayout>
<LinearLayout
android:id="@+id/drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:orientation="vertical" >
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
<LinearLayout
android:id="@+id/drawer_right"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_gravity="end"
android:gravity="center_horizontal|center_vertical"
android:orientation="vertical" >
<ListView
android:id="@+id/listView2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
将代码替换为:
getSlidingMenu().setMode(SlidingMenu.LEFT_RIGHT);
getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
setBehindContentView(R.layout.menu_right);
getSupportFragmentManager().beginTransaction().replace(R.id.menuRight, new MenuRightFragment()).commit();
getSlidingMenu().setSecondaryMenu(R.layout.menu_left);
getSupportFragmentManager().beginTransaction().replace(R.id.menuLeft, new MenuLeftFragment()).commit();
在MenuRightFragment()和MenuLeftFragment()中创建两个单独的列表类。您是否使用了
Fragment
class?是@Shayan pourvatan。因此,在那里处理该问题或为您的菜单调用不同的Fragment。您也可以使用android默认抽屉布局来实现这一点,而不使用库。从屏幕中心滑动时菜单不打开,仅在从marginHey Dude滑动时才起作用。请更改它sm.设置触摸模式(左滑动菜单);至sm.SetTouchMode(左/右滑动菜单)