如何从viewpager获取Exact页面位置?

时间:2013-05-10 13:28:05

标签: android android-viewpager

从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;
    } 

1 个答案:

答案 0 :(得分:0)

尝试pageView.getCurrentItem();