The first thing to say is that the interface is sliding, you need multiple view to switch, you can actually use a arraylist<view> pageviews to save the view information, and then switch
Layoutinflater inflater = Getlayoutinflater ();p ageviews = new arraylist<view> ();p Ageviews.add (inflater.inflate (R.LAYOUT.ITEM01, null)); Pageviews.add (inflater.inflate (r.layout.item02, null));p Ageviews.add (inflater.inflate (r.layout.item03, null));
And then define each item01,item02,item03 XML file.
<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools "> <linearlayout android:id=" @+id/linearlayout1 " android:layout_ Width= "Match_parent" android:layout_height= "wrap_content" android:orientation= "vertical" > < ImageView android:layout_width= "fill_parent" android:layout_height= "Wrap_content" android: background= "@drawable/feature_guide_0" > </ImageView> </linearlayout></linearlayout >
What I wrote on it was a relatively simple imageview to make an item,
It has to be said that you must define a class Guidpagechangelistener to inherit the Onpagechangelistener interface to achieve the switch between the view
public void onpageselected (int arg0) {//TODO auto-generated method stubfor (int i = 0; i < imageviews.length; i++) {IM Ageviews[arg0].setbackgroundresource (r.drawable.page_indicator_focused); if (arg0! = i) {imageviews[i]. Setbackgroundresource (R.drawable.page_indicator);}}}
We also need an adapter Pageradapter class, we write our own class to inherit it
Class Guidpageadapter extends Pageradapter
The main references are the following methods
Class Guidpageadapter extends Pageradapter {@Overridepublic int getcount () {//TODO auto-generated method Stubreturn Pagev Iews.size ();} @Overridepublic boolean isviewfromobject (View arg0, Object arg1) {//TODO auto-generated method Stubreturn arg0 = arg1;} @Overridepublic void Destroyitem (View arg0, int arg1, Object arg2) {//TODO auto-generated Method Stub ((Viewpager) arg0). R Emoveview (Pageviews.get (Arg1));} @Overridepublic Object Instantiateitem (View arg0, int arg1) {//TODO auto-generated Method Stub ((Viewpager) arg0). AddView (Pageviews.get (arg1)); return Pageviews.get (ARG1);}}
This allows a simple view of the left and right sliding switch, the switch when the full screen switch, about the half-screen sliding switch back to continue
Reprint please indicate the source
http://blog.csdn.net/pishum/article/details/38024331
Android implementation left and right swipe interface