我有一个应用程序,我使用ViewPager进行滑动。到目前为止,我只能刷RightToLeft。我想要的是滑动RightToLeft,向下滑动并向上滑动。我有3个片段,但它只刷了RightToLeft。
ReflectionTestUtils.setField(new FxRatesEventPublisher(),"maxRecoveryAge",1,int.class);
ReflectionTestUtils.setField(new FxRatesEventPublisher(),"maxRecoveryAge",5,int.class);
ReflectionTestUtils.setField(new FxRatesEventPublisher(),"maxRecoveryAge",24,int.class);
}
这是ViewPager代码
public class MainActivity extends FragmentActivity {
FragmentPagerAdapter adapterViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
CustomViewPager vpPager = (CustomViewPager) findViewById(R.id.view_pager);
adapterViewPager = new MyPagerAdapter(getSupportFragmentManager());
vpPager.setAdapter(adapterViewPager);
vpPager.getCurrentItem();
// Attach the page change listener inside the activity
vpPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
// This method will be invoked when a new page becomes selected.
@Override
public void onPageSelected(int position) {
}
// This method will be invoked when the current page is scrolled
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
// Code goes here
}
// Called when the scroll state changes:
// SCROLL_STATE_IDLE, SCROLL_STATE_DRAGGING, SCROLL_STATE_SETTLING
@Override
public void onPageScrollStateChanged(int state) {
// Code goes here
}
});
}
public static class MyPagerAdapter extends FragmentPagerAdapter {
private static int NUM_ITEMS = 3;
public MyPagerAdapter(FragmentManager fragmentManager) {
super(fragmentManager);
}
// Returns total number of pages
@Override
public int getCount() {
return NUM_ITEMS;
}
// Returns the fragment to display for that page
@Override
public Fragment getItem(int position) {
switch (position) {
case 0: // Fragment # 0 - This will show FirstFragment
return FirstFragment.newInstance(0);
case 1:
return SecondFragment.newInstance(1);
case 2:
return ThirdFragment.newInstance(2);
default:
return null;
}
}
}
}
任何可以帮助我添加2个swioe指示的人?