Android ViewPager get the current View

前端 未结 15 2371
天命终不由人
天命终不由人 2020-11-28 06:24

I have a ViewPager, and I\'d like to get the current selected and visible view, not a position.

  1. getChildAt(getCurrentItem) returns wrong Vi
15条回答
  •  借酒劲吻你
    2020-11-28 06:44

    If you examine carefully, there are at most 3 views saved by ViewPager. You can easily get the current view by

    view     = MyActivity.mViewPager.getChildAt(1);
    

提交回复
热议问题