Android uses viewpager for navigation

First, understand that the effect of viewpager is to slide the view left and right.

The declaration of viewpager in XML file is a little different from that of some other controls

Android.support.v4.view is a jar package loaded by a third party with special effects of Android interface, which can be downward compatible.

Load the displayed page card: the layout file needs to be transformed into a view object

You can also know from the naming that these two are used to set the title, just like the directory (wechat, address book, discovery and I) displayed at the bottom of the wechat main interface, which can navigate the page title the user slides to.

In general, one of the two can be used. If both are used at the same time, pagertabstrip will become invalid

Of course, pagertabstrip and pagertitlestrip also beautify the navigation directory by setting some properties

There are three different adapters corresponding to viewpager, and the corresponding data sources are also different

(1) Pageradapter -- data source: List < View >

(2) Fragmentpageradapter -- data source: List < fragment >

(3) Fragmentstatepageradapter -- data source: List < fragment >

There is no code posted here. The code of fragmentstatepageradapter is not much different from that of fragmentpageradapter. The difference between the two is that one will call the destroy method to destroy the page card after sliding, while the other will not destroy the page card.

Finally, the listener. Viewpager uses the onpagerchangelister listener to listen to which page it slides to. The common method in the middle is public void onpagerselected (int arg0) {}

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!

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