결과화면

 

 package com.example.widgetdemo1;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ViewFlipper;

public class FlipperDemo extends Activity implements View.OnClickListener {
 Button prev, next;
 ViewFlipper flipper;

 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.flipperdemo_1);
  
  flipper = (ViewFlipper)findViewById(R.id.flipper);
  prev = (Button)findViewById(R.id.prev);
  next = (Button)findViewById(R.id.next);
  
  prev.setOnClickListener(this);
  next.setOnClickListener(this);
 }
 
 @Override
 public void onClick(View v){
  //prev 버튼이 클릭되었을 때
  if(v == prev){
   flipper.showPrevious();    
  } else if(v == next){
   flipper.showNext();
  }
 }
}

 

 

 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
   
    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >
   
    <Button
        android:id="@+id/prev"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="이전"/>

    <Button
        android:id="@+id/next"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="다음"/>
    </LinearLayout>
   
    <ViewFlipper
        android:id="@+id/flipper"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
   
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="RED"
        android:background="#ff0000" />
   
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="GREEN"
        android:background="#00ff00" />
   
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="BLUE"
        android:background="#0000ff" />
    </ViewFlipper>

</LinearLayout>

 

'2020년도 이전 > [WebSig] Android' 카테고리의 다른 글

이클립스에서 logcat이 안보인다면?  (0) 2013.08.16
Sliding Demo - 슬라이딩드로어  (0) 2013.08.16
GridView Demo  (0) 2013.08.14
ExpandableList ViewDemo  (0) 2013.08.14
ListView Demo5  (0) 2013.08.14

+ Recent posts