The usage of the options described in the previous sections basically uses tabactivity and viewpager to meet the development requirements. However, here is another tips. Sometimes, when using viewpager and fragment in front of the page, you may feel a little useless.
Http://blog.csdn.net/xia215266092/article/details/9613897
Http://blog.csdn.net/xia215266092/article/details/9613985
Http://blog.csdn.net/xia215266092/article/details/9616075
For example, in the following case, there is a tab in the Weibo interface. All tabs, I listened to, and authenticated users can be implemented if viewpager + fragment is used. However, today I will introduce the use of viewflipper to view the API documentation. viewflipper can contain many classes, but only one view can be displayed at a time, in this way, the switch between labels in the image is basically satisfied.
The layout structure can be as follows.
<Viewflipper>
<Listview/>
<Listview/>
<Listview/>
</Viewflipper>
The following is the method for switching the page. shownext and shorpervious are the previous and next Display respectively. setdisplayedchild is the specific display of a subview, And the passed parameter is the position of ziview.
Void |
Shownext () Manually shows the next child. |
Void |
Showprevious () Manually shows the previous child. |
Void |
Setdisplayedchild (int Whichchild) Sets which child view will be displayed. |
Another advantage of using viewflipper is that you can easily customize the animation during switching.
Void |
Setinanimation (animation inanimation) Specifies the animation used to animate a view that enters the screen. |
Void |
Setoutanimation (animation outanimation) Specifies the animation used to animate a view that exit the screen. |
The first is the animation when the view comes in, and the second is the animation when the view goes out. If the animation is set well, the effect is also very good. If the above animation is set, you can set loop and automatically play all pages, similar to gallery. If you want to learn more, you still need to view the documentation.
Public class
Viewanimator
Extends framelayout
Java. Lang. Object |
Bytes |
Android. View. View |
|
Bytes |
Android. View. viewgroup |
|
|
Bytes |
Android. widget. framelayout |
|
|
|
Bytes |
Android. widget. viewanimator |
Known Direct subclassesViewflipper, viewswitcher |
Known Indirect subclassesImageswitcher, textswitcher |
Viewanimator and viewflipper, viewswticher, imageswitch, and textswitcher have similar functions, but they only apply to different objects.