因为项目的需求找了下viewpager是否可以竖直滑动,貌似还真不行,就找到了VerticalAdapter,从网上找到了一个例子,但是那个例子对按钮没有反应
修改后,按钮可以响应,具体如下
1、extends ActivityGroup,类要继承ActivityGroup
2、
@SuppressWarnings("deprecation")
ArrayList<View> views = new ArrayList<View>();
@SuppressWarnings("deprecation")
View view1 = getLocalActivityManager().startActivity("activity01",
new Intent(this, A.class)).getDecorView();
@SuppressWarnings("deprecation")
View view2 = getLocalActivityManager().startActivity("activity02",
new Intent(this, B.class)).getDecorView();
@SuppressWarnings("deprecation")
View view3 = getLocalActivityManager().startActivity("activity03",
new Intent(this, C.class)).getDecorView();
@SuppressWarnings("deprecation")
View view4 = getLocalActivityManager().startActivity("activity04",
new Intent(this, D.class)).getDecorView();
views.add(view1);
views.add(view2);
views.add(view3);
views.add(view4);
VerticalAdapter vAdapter1 = new VerticalAdapter(views);
mViewPager.setAdapter(vAdapter1);
mViewPager.setCurrentItem(position);
mViewPager.setOnPageChangeListener(new OnPageChangeListener() {
@Override
public void onPageScrollStateChanged(int state) {
}
public void onPageSelected(int arg0) {
}
@Override
public void onPageScrolled(int position, float positionOffset,
int positionOffsetPixels) {
}
});
附三个类地址:http://download.youkuaiyun.com/detail/shan1021/6239309