Android solves the problem that the interface does not refresh when notifydatasetchanged() is called by viewpage

Android solves the problem that the interface does not refresh when notifydatasetchanged() is called by viewpage

Problem description

I believe many people who have done viewpager must have encountered this problem. Whether this is a bug or Android is designed in this way, we won't discuss it. In short, it does affect the implementation of our functions.

Many students may choose to reset the adapter for viewpager to refresh. But this method is problematic in most cases.

terms of settlement

So we can try to modify the writing method of the adapter, override the getitemposition () method, and let the getitemposition method return position artificially when notifydatasetchanged is called_ None to force the viewpager to redraw all items.

The specific codes are as follows:

If you have any questions, please leave a message or go to the community of this site for exchange and discussion. Thank you for reading. I hope it can help you. Thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>