从ViewPager打印当前位置时会感到困惑。我搜索了它并从stackoverflow获得了一个解决方案。但我想知道是否有可能在更改页面时从viewpager连续获取确切的布局位置。实际上我想在instantiateItem方法中获取当前位置。可能吗。这是我的代码:
@Override
public Object instantiateItem(ViewGroup container, int position) {
// using the position parameter, inflate the proper layout, also add
// it to the container parameter
ViewGroup pageView = (ViewGroup) mInflater.inflate(
mLayouts[position], container, false);
container.addView(pageView);
return pageView;
}
答案 0 :(得分:0)
尝试pageView.getCurrentItem();