ViewFlipper
ViewFlipper flips the view with the values given to its adapter. The flipping rate can be modified to make it flip faster or slower
Layout file for the activity
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ViewFlipper android:id="@+id/flippy"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</ViewFlipper>
</LinearLayout>
Activity class for the ViewFlipper
public class MainActivity extends AppCompatActivity {
static String[] items={"answer1", "answer2", "answer3"};
ViewFlipper flipper;
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
setContentView(R.layout.activity_main);
flipper=(ViewFlipper)findViewById(R.id.flippy);
for (String item : items) {
Button btn=new Button(this);
btn.setText(item);
flipper.addView(btn,
new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT));
}
flipper.setFlipInterval(2000);
flipper.startFlipping();
}
}