Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
32 lines (22 sloc) 524 Bytes

定义

ViewPager mMyViewPager;

private static class MyPagerAdapter extends PagerAdapter {
  // ...

  @Override
  public Object instantiateItem(ViewGroup view, final int position) {
    View itemView = ...; // new or inflate
    
    // ...
    
    itemView.setTag(position);
    
    view.add(itemView, 0);
    
    return itemView;
  }

  // ...
}

使用

View currentItemView = mMyViewPager.findViewWithTag(mMyViewPager.getCurrentItem());

参考

http://stackoverflow.com/a/11176510/2782426