파일명 : activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
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/btnPrev"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=" 이전화면 " />
<Button
android:id="@+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=" 다음화면 " />
</LinearLayout>
<ViewFlipper
android:id="@+id/viewFlipper1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff0000" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="sadfasdfs"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00ff00" >
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="성별"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0000ff" >
</LinearLayout>
</ViewFlipper>
</LinearLayout>
파일명 : MainActivity.java
package com.example.it.myapplication6_16;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ViewFlipper;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btnPrev, btnNext;
final ViewFlipper vFlipper;
btnPrev = (Button) findViewById(R.id.btnPrev);
btnNext = (Button) findViewById(R.id.btnNext);
vFlipper = (ViewFlipper) findViewById(R.id.viewFlipper1);
vFlipper.setFlipInterval(1000);
btnPrev.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//vFlipper.showPrevious(); // 앞 화면으로 이동
vFlipper.startFlipping(); // 순차적으로 자동 페이지 전환
}
}
);
btnNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//vFlipper.showNext(); // 뒤 화면으로 이동
vFlipper.stopFlipping(); // 자동페이지 전환 멈추기
}
}
);
}
}
'IT > Android' 카테고리의 다른 글
android - 액션바(ActionBar)와 프래그먼트(Fragment)를 활용하여 화면 구현 (0) | 2018.09.19 |
---|---|
android - TabHost와 LinearLayout, TabHost와 ImageView (0) | 2018.09.17 |
android - ProgressBar, SeekBar, RatingBar, ScrollView, SlidingDrawer (0) | 2018.09.16 |
android - AutoCompleteTextView, MultiAutoCompleteTextView (0) | 2018.09.15 |
android - FrameLayout , Chronometer, TimePicker, CalendarView (0) | 2018.09.10 |