Android Learning-Interface-ui-adapterviewflipper

Source: Internet
Author: User

Like gallery, but this is a picture page

Properties method Description
 android:animat Efirstview  setanimatefirstview (boolean animate)   whether to use animation when displaying the first view
 android:inanimation  setinanimation (objectanimator inanimation) View display animation, no use, direct error
 android:outanimation  setoutanimation (objectanimator outanimation) view hidden animation  , no use, direct error
 android:loopviews   ;   Whether the loop is displayed, the last one to come is the first one
 android:autostart  startflipping ()   whether AutoPlay
 android:flipinterval  setflipinterval (int flipinterval)     AutoPlay time Interval

Example

Item.xml

<LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent" >    <ImageViewAndroid:id= "@+id/imageview1"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content" />    <TextViewAndroid:id= "@+id/textview1"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "Large Text"android:textappearance= "? Android:attr/textappearancelarge"                 /></LinearLayout>
View Code

Activity_main.xml

<LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:id= "@+id/linearlayout1"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent"android:orientation= "vertical"android:padding= "10DP" >    <LinearLayoutAndroid:layout_width= "Match_parent"Android:layout_height= "Wrap_content" >        <ButtonAndroid:id= "@+id/button1"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "Previous" />        <ButtonAndroid:id= "@+id/button2"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "Next" />        <ButtonAndroid:id= "@+id/button3"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "AutoPlay" />    </LinearLayout>    <AdapterviewflipperAndroid:id= "@+id/adapterviewflipper1"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"   >    </Adapterviewflipper></LinearLayout>
View Code

Mainactivity.java

 Packagecom.example.ddd;Importjava.util.ArrayList;ImportJava.util.HashMap;Importjava.util.List;ImportJava.util.Map;Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.view.View;ImportAndroid.view.View.OnClickListener;Importandroid.view.animation.Animation;Importandroid.view.animation.AnimationUtils;ImportAndroid.widget.AdapterViewFlipper;ImportAndroid.widget.Button;ImportAndroid.widget.SimpleAdapter; Public classMainactivityextendsActivityImplementsonclicklistener{Adapterviewflipper AdapterViewFlipper1; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);                Setcontentview (R.layout.activity_main); List<Map<String,Object>> items=NewArraylist<map<string,object>>(); Map<String,Object> map1=NewHashmap<string,object> (); Map1.put ("Name", "Huawei"); Map1.put ("Pic", R.drawable.pic1);        Items.Add (MAP1); Map<String,Object> map2=NewHashmap<string,object> (); Map2.put ("Name", "Apple"); Map2.put ("Pic", R.drawable.pic2);        Items.Add (MAP2); Map<String,Object> map3=NewHashmap<string,object> (); Map3.put ("Name", "Samsung"); Map3.put ("Pic", R.DRAWABLE.PIC3);           Items.Add (MAP3); Simpleadapter SA=NewSimpleadapter (mainactivity. This, Items,r.layout.item,Newstring[]{"name", "Pic"},New int[]{r.id.textview1,r.id.imageview1}]; AdapterViewFlipper1=(Adapterviewflipper) Findviewbyid (r.id.adapterviewflipper1);                Adapterviewflipper1.setadapter (SA); Button BTN1=(Button) Findviewbyid (R.id.button1); Button btn2=(Button) Findviewbyid (R.id.button2); Button Btn3=(Button) Findviewbyid (R.id.button3); Btn1.setonclicklistener ( This); Btn2.setonclicklistener ( This); Btn3.setonclicklistener ( This); } @Override Public voidOnClick (View v) {if(V.getid () = =R.id.button1) {            //the previous oneadapterviewflipper1.showprevious (); }        Else if(V.getid () = =R.id.button2) {            //Next OneAdapterviewflipper1.shownext (); }        Else if(V.getid () = =R.id.button3) {Adapterviewflipper1.setflipinterval (5000);    Adapterviewflipper1.startflipping (); }    }}
View Code

Android Learning-Interface-ui-adapterviewflipper

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.