从左到右,从右到左的Android滑动面板 [英] Left to right and right to left android sliding panel
问题描述
我看到一对夫妇库,能做到这一点,但我想如果可能的话,以避免它们。我设法做左到右,但我无法找出如何在两个方向上做的。所以这里是我的code:
I saw a couple libraries that can do this, but i would like to avoid them if possible. I managed to do left to right, but i couldn't find out how to do on both directions. so here is my code:
final SlidingPaneLayout slidingPaneLayout = SlidingPaneLayout.class.cast(root.findViewById(R.id.slidingpanelayout));
slidingPaneLayout.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() {
@Override
public void onPanelSlide(View view, float v) {
}
@Override
public void onPanelOpened(View view) {
switch (view.getId()) {
case R.id.fragment_secondpane:
getSupportFragmentManager().findFragmentById(R.id.fragment_firstpane).setHasOptionsMenu(true);
getSupportFragmentManager().findFragmentById(R.id.fragment_secondpane).setHasOptionsMenu(false);
break;
default:
break;
}
}
@Override
public void onPanelClosed(View view) {
switch (view.getId()) {
case R.id.fragment_secondpane:
getSupportFragmentManager().findFragmentById(R.id.fragment_firstpane).setHasOptionsMenu(false);
getSupportFragmentManager().findFragmentById(R.id.fragment_secondpane).setHasOptionsMenu(true);
break;
default:
break;
}
}
});
有没有一种方法,使滑动面板上都从左到右,从右到左的方向,这样我将有3个片段,没有任何库?
is there a way to make sliding panels on both left to right and right to left directions so that i will have 3 fragments, without any libraries?
推荐答案
您解决之道在于 ViewPager
。这里有一对夫妇为教程链接。
Your solution lies in ViewPager
. Here are a couple of links for tutorial.
<一个href=\"http://www.edumobile.org/android/android-beginner-tutorials/view-pager-example-in-android-development/\"相对=nofollow>与源$ C $ c和XML文件详细教程
<一个href=\"http://www.vogella.com/$c$c/de.vogella.android.viewpager/src/de/vogella/android/viewpager/ViewPagerActivity.html\"相对=nofollow> Vogella教程的ViewPage
更新
你所要求的是抽屉式导航
。你可以找到吨教程互联网上。这里有一些很好的。
What you are asking about is Navigation Drawer
. You can find tons of tutorial on internet. Here are some good ones.
为Beginers 详细的教程
希望这有助于
这篇关于从左到右,从右到左的Android滑动面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!