我正在通过 SwipeyTabsAdapter 的库 ViewPager ViewPagerExtensions (com.astuetz.viewpager.extensions) 水平实现一个。有没有办法在改变观点时拦截?同样,我可以随时知道用户的观点是什么?
ViewPager 的代码
public class DiccionariuPagerAdapter extends PagerAdapter {
protected transient Activity mContext;
private int mLength = 0;
public DiccionariuPagerAdapter(Activity context, int length) {
mContext = context;
mLength = length;
}
@Override
public int getCount() {
return mLength;
}
@Override
public Object instantiateItem(View container, int position) {
RelativeLayout v = new RelativeLayout(mContext);
View vi; // Creating an instance for View Object
LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (position == 0) {
vi = inflater.inflate(R.layout.diccionariu, null);
}
else if (position == 1) {
vi = inflater.inflate(R.layout.conxugar, null);
}
else {
vi = inflater.inflate(R.layout.traducir, null);
}
v.addView(vi);
//v.addView(t);
((ViewPager) container).addView(v, 0);
startUpdate(container);
return v;
}
@Override
public void destroyItem(View container, int position, Object view) {
((ViewPager) container).removeView((View) view);
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == ((View) object);
}
@Override
public void finishUpdate(View container) {}
@Override
public void restoreState(Parcelable state, ClassLoader loader) {}
@Override
public Parcelable saveState() {
return null;
}
@Override
public void startUpdate(View container) {}
}
非常感谢您