How do I get the child View of a ViewPager at a given item

后端 未结 5 440
北恋
北恋 2020-12-05 17:54

I\'ll keep the question as short and simple as humanly possible.

View activeView = mViewPager.getChildAt(mViewPager.getCurrentItem());

retu

5条回答
  •  醉酒成梦
    2020-12-05 18:50

    During my endeavors to find a way to decorate android views I think I defined alternative solution for th OP's problem that I have documented in my blog. I am linking to it as the code seems to be a little bit too much for including everything here.

    The solution I propose:

    • keeps the adapter and the view entirely separated
    • one can easily query for a view with any index form the view pager and he will be returned either null if this view is currently not loaded or the corresponding view.

    (This question is very simple to this one in which I have posted the same answer).

提交回复
热议问题