Android uses gallery and imageswitch to make a picture browser that can slide left and right
design sketch:
In order to make the picture browser slide around indefinitely, we need to customize the gallery adapter
If you want to customize the adapter, you must first understand these methods
Where getcount method is to return the number of data sources
The getitem method returns an object object, that is, the object corresponding to the data ID position in the current container
Getitemid returns the data ID in the current container
Getview gets the view to be displayed
If we want to realize the left-right circular sliding, first we need to return the number of data sources as the maximum value, then take the ID of all data to the number of original data sources, and finally set the initial position of gallery in the middle of 0-maximum value
The changed adapter is like this
MainActivity
The above is the whole content of this article. I hope the content of this article can bring some help to your study or work. At the same time, I also hope to support a lot of programming tips!