1 <LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"2 Xmlns:tools= "Http://schemas.android.com/tools"3 Android:layout_width= "Match_parent"4 Android:layout_height= "Match_parent"5 android:orientation= "vertical" >6 7 <TextView8 Android:layout_width= "Wrap_content"9 Android:layout_height= "Wrap_content"Ten Android:text= "@string/hello_world" /> One A <Viewflipper - Android:id= "@+id/flipper" - Android:layout_width= "Match_parent" the Android:layout_height= "Wrap_content" - Android:layout_alignparenttop= "true" - Android:layout_margintop= "10DP" - Android:flipinterval= "$" > + - <TextView + Android:id= "@+id/text_1" A Android:layout_width= "Match_parent" at Android:layout_height= "Wrap_content" - Android:text= "Text_1" /> - - <TextView - Android:id= "@+id/text_2" - Android:layout_width= "Match_parent" in Android:layout_height= "Wrap_content" - Android:text= "Text_12" /> to + <TextView - Android:id= "@+id/text_3" the Android:layout_width= "Match_parent" * Android:layout_height= "Wrap_content" $ Android:text= "Text_13" />Panax Notoginseng - <TextView the Android:id= "@+id/text_4" + Android:layout_width= "Match_parent" A Android:layout_height= "Wrap_content" the Android:text= "Text_14" /> + </Viewflipper> - $ <Button $ Android:id= "@+id/btn" - Android:layout_width= "Wrap_content" - Android:layout_height= "Wrap_content" the Android:text= "Stop" /> - Wuyi </LinearLayout>
1 PackageCom.example.demoviewfliper;2 3 Importandroid.app.Activity;4 ImportAndroid.os.Bundle;5 ImportAndroid.view.View;6 ImportAndroid.widget.Button;7 ImportAndroid.widget.ViewFlipper;8 9 Public classMainactivityextendsActivity {Ten Viewflipper mVf; One Button btn; A - @Override - protected voidonCreate (Bundle savedinstancestate) { the Super. OnCreate (savedinstancestate); - Setcontentview (r.layout.activity_main); - -MVf =(Viewflipper) Findviewbyid (r.id.flipper); + mvf.startflipping (); - +BTN =(Button) Findviewbyid (R.ID.BTN); ABtn.setonclicklistener (NewView.onclicklistener () { at - @Override - Public voidOnClick (View v) { - if(MVf! =NULL&&mvf.isflipping ()) { - mvf.stopflipping (); -Mvf.setdisplayedchild (Mvf.getchildcount ()-1); in } - to } + }); - } the *}
Android image flashing (delay switching)