What is a good approach to Flip through many (over 40) images?
Ive looked into the ViewFlipper, but defining 40 different views in one XML doc just doesn't seem like a bright idea. I know there has to be a better way, I just don't know how. I have spent some time trying to find 开发者_如何转开发a answer with no good answer so far.
I have used the Gallery widget (admittedly quite heavily modified) to display 200 fullscreen images in an image viewer for a client.
Alternatively you could use a ViewAimator with either 2 (in this case ViewFlipper) or 3 views (3 if you want to preload both the next and previous images). If you go for this approach then Laurence beat me to suggesting this idea ;) However I'd add that you would want to extend the ViewAnimator/ViewFlipper class to allow it to accept some type of Adapter.
A simple approach would be to simply contain two ImageViews within the ViewFlipper. Then when you request the next or previous view, set the new image resource for the next view and flip.
If you implement a lazy loader using AsyncTask or a Handler this will stop your UI thread from blocking.
Hope this helps!
You could use a ViewPager (included in the Android compatibility library if you need to support pre-Honeycomb devices).
精彩评论