Multiple PagedView Issue In Greendroid

While currently working on a new app, I decided to use a PagedView with 3 screens. I was surprised that the 3rd screen will always show what is displayed in the first screen. I tested to see what would happen if I use 4 screens. The same thing happened: the 4th screen displayed the contents of the 2nd screen.

I was confused why it acted like this. Instantiating new views on the 3rd and 4th position will work. However, I wanted to find a way where the views had to be reused rather than creating new instances because more memory will be used.

I asked Cyril, the creator of Greendroid if this is a bug or not. This is his answer.

The PagedView is based on a reuse mechanism really similar to the one used by ListView. As a result, once a new page is required, the PagedView asks the PagedAdapter a new page trying to reuse a old page (that is a page that is no longer visible on screen).
This is the reason why you have at most 2 pages instantiated : you have to reuse the previously created pages.
If your pages are really different, you can by-pass this behavior by not reusing the convertView. Just keep in mind having a very small number of pages as it will probably imply having a large number of pages in memory at the same time (hence a large number of Views).

I guess having multiple paged views at 3 screens is enough. Going beyond that is probably overkill. If you can make it up to 2 screens only, then the better.

Related Posts Plugin for WordPress, Blogger...

Leave a Reply

Your email address will not be published. Required fields are marked *