Implementation of horizontal movement of Android viewpager album

When we download QQ for the first time and open it, there will be a novice guide. The guide is a few pictures, plus some text descriptions. Slide to the right until the end. I got up early this morning and studied the viewpager control for the implementation of this effect.

The following example will use viewpager to move photo albums horizontally. Viewpager has a corresponding pageradapter for binding data; We need to inherit this class and implement our own functions.

1. First, define the data object imageitem that a display item needs to use

2. Each side of the viewpager is an item, so define an item of each page of the viewpager in the layout directory, named pageritem.xml

3. Create a new Java file corresponding to each item of viewpager

4. Create a new data filler pageriteminadapter, which inherits from pagertadapter

5. Add a viewpager control to the main.xml file

6. Modify mainactivity as follows:

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
分享
二维码
< <上一篇
下一篇>>