public class AuditFragment extends BaseFragment {
private ViewPager viewPager;
private CustomViewPagerAdapter customViewPagerAdapter;
private List<View> mListViews;
private List<String> mlist;
Context context= FbApplication.getInstance();
private int lastValue = -1;
private boolean isLeft = true;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view=inflater.inflate(R.layout.fragment_list_layout,container,false);
customViewPagerAdapter=new CustomViewPagerAdapter(mListViews);
viewPager= (ViewPager) view.findViewById(R.id.viewpager);
viewPager.setAdapter(customViewPagerAdapter);
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int i, float v, int i1) {
if (v != 0){
if (lastValue >= i1){
// 右滑
isLeft = false;
}else if(lastValue<i1){
// 左滑
isLeft = true;
}
}
lastValue = i1;
}
@Override
public void onPageSelected(int i) {
if (isLeft){
Toast.makeText(context,R.string.Swipe_right_title,Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(context,R.string.Swipe_left_title,Toast.LENGTH_SHORT).show();
}
}
@Override
public void onPageScrollStateChanged(int i) {
}
});
initview();
return view;
}
private void initview() {
mListViews=new ArrayList<View>();
View mview1= LayoutInflater.from(context).inflate(R.layout.fragment_v_item,null);
ListView listView1= (ListView) mview1.findViewById(R.id.list);
// View mview2= LayoutInflater.from(context).inflate(R.layout.fragment_v_item,null);
// ListView listView2= (ListView) mview1.findViewById(R.id.list);
mListViews.add(listView1);
// mListViews.add(listView2);
}
}
为梦想努力_冬
相关分类