As required, I need to obtain the current view of viewpager.
So I used the following statement:
View currentview = mviewpager. getchildat (mviewpager. getcurrentitem ());
Then I took this view to do other things, but after sliding more than three views, I found it was null, mviewpager. when getcurrentitem () exceeds 2, it is null. This indicates that viewpager is reused by three views.
What should we do?
Reprinted please indicate the source: http://blog.csdn.net/ethan_xue/article/details/7890888
With the help of Google Baidu, we can use findviewwithtag.
In the onpageselected () method in the listener of viewpager, set the tag for the view.
Itemview. settag (currentid );
Then, you only need to find the tag.
View currentview = mviewpager. findviewwithtag (mviewpager. getcurrentitem ()
References:
Http://www.coder007.net/questions/1401/androi-viewpaper-view-childview
Http://www.apkbus.com/blog-90729-39689.html
Http://blog.sina.com.cn/s/blog_7033e38201015kwe.html