Android Rewrite Viewpager

Source: Internet
Author: User

Rewrite Viewpager when calling Getchildat (position) in Viewpager, many of the retrieved view are null

The information was found because I called ((Viewpager) container) when I was instantiateitem. AddView (view);

should be written ((Viewpager) container). AddView (view, position);

Error after operation, index out of bounds

Also check is because the Viewpager inside the default amount of storage is limited, should be viewpager in order to minimize the memory to do so

To make AddView meet my requirements (I need to show 5 pages)

To invoke a Viewpager method

Viewpager.setoffscreenpagelimit (5);

Set the minimum number of pages

That's right when you call Getchildat.


Another way is to create a map to put the created view into this map.

When you need to get the view, get the view through this map get

It's also possible.


My idea is: Anyway, there is no way to save memory in this view.

So just put it in the Viewpager.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.