¿ì¸®°¡ ¾ÛÀ» Á¦ÀÛÀ» ÇÏ´Ùº¸¸é
ÀûÀº Viewµé·Î ¸¶Ä¡ ¿©·¯°³ÀÇ ViewµéÀÌ Á¸ÀçÇϴ°Ͱú °°Àº È¿°ú¸¦ ³»±â À§Çؼ
Flipper¸¦ ¸¹À̾¹´Ï´Ù.
°¡Àå ´ëÇ¥ÀûÀÎ ¿¹°¡ Jorte¶ó´Â ¾Û¿¡¼ ´Þ·ÂÀ» º¸½Ç¶§
Çø³À» ÇÏ°ÔµÇ¸é »õ·Î¿î ºä¿¡ »õ·Î¿î ´Þ·ÂÀÌ ¶ß°Ô µÇÁÒ
ÀϹÝÀûÀ¸·Î »ý°¢Çغ¸¸é Çø³ÇÒ¶§¸¶´Ù ¾Æ¿¹ »õ·Î¿î ºä°¡ µ¿ÀûÀ¸·Î »ý¼ºµÇ¼ °è¼ÓÃß°¡µÇ´Â°Í °°Áö¸¸
»ç½Ç ±×·¸Áö´Â ¾Ê½À´Ï´Ù.
ViewFlipper¸¦ ÀÌ¿ëÇÑ°ÍÀä.
¿ì¼± ±¸Á¶¸¦ ¾Ë¾Æ¾ß°Ú½À´Ï´Ù.
ViewFlipper´Â Flipper¾È¿¡ ¿©·¯°³ÀÇ ºäµéÀ» ´ã¾ÆµÎ°í ±×°ÍÀ» ¾È¿¡¼ »±±Û»±±Û µµ´Â ¹æ½ÄÀÔ´Ï´Ù.
ÀϹÝÀûÀÎ ÀڷᱸÁ¶·Î ¼³¸íÇÏÀÚ¸é ¿øÇü¸®½ºÆ®¸¦ »ý°¢ÇϽøéµË´Ï´Ù.
¿¹¸¦ µé¾î ¼³¸íÇÏÀÚ¸é
[1_view] [2_view] [3_view]
ÀÌ·¸°Ô 3°³ÀÇ ºäµéÀÌ Á¸ÀçÇÕ´Ï´Ù.
Çø®ÆÛ·Î ViewFlipper vi ; vi.showPreVious(); //ÀÌÀüView È£Ãâ.
¸¦ È£ÃâÇÏ°Ô µÇ¸é. 1_view°¡ ±âº»À϶§ 2_view¸¦ °¡¸®Å°´Â°ÍÀÌ ¾Æ´Ñ ½Ã°è¹æÇâÀ¸·Î
3_view¸¦ °¡¸®Å°¸é¼ È£ÃâÇÕ´Ï´Ù.
±×¸®°í ´Ù½Ã vi.showPreVious();¸¦ È£ÃâÇϰԵǸé 2_view¸¦ °¡¸®Å°¸é¼ È£ÃâÇÏ°Ô µË´Ï´Ù.
¹Ý´ë·Î vi.showNext();//´ÙÀ½ViewÈ£Ãâ
¸¦ È£ÃâÇϰԵǸé 1_view°¡ ÇöÀç È£ÃâµÈ viewÀÏ ½Ã ½Ã°è¹Ý´ë¹æÇâÀ¸·Î µ½´Ï´Ù.
2_view -> 3_view -> 1_view
ÀÌ·±½ÄÀ¸·Î.
²¿¸®ÀÇ ²¿¸®¸¦ ¹«´Â ¹æ½ÄÀ» °¡Áø ¸®½ºÆ®¸¦ ¿øÇü¸®½ºÆ®¶ó°í ºÎ¸¨´Ï´Ù.
±×·¸´Ù¸é ¿ì¸®°¡ Çø³À» »ç¿ëÇÒ¶§ °á±¹ »ç¿ëÇؾߵǴ ViewÀÇ ¼ö´Â ÃÖ´ë 3°³»ÓÀ̸ç,
±×À̻󸸵éÇÊ¿ä°¡¾ø°ÔµÇ¾î heap¿¡¼ ³²´Â°ø°£ÀÌ Á»´õ ¸¹¾ÆÁö°ÙÁÒ?
±×·³ °£´ÜÇÑ ±¸Çö¹æ½ÄÀ» ¼Ò°³ÇÕ´Ï´Ù.
//¼Ò½º
//////////////
FlipperTest.java;
//////////////
package com.corea.FlipperTest;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.ViewFlipper;
public class FlipperTestActivity extends Activity {
/** Called when the activity is first created. */
ViewFlipper Vf;
TextView txt1;
TextView txt2;
TextView txt3;
Button btn1;
Button btn2;
int a =10;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Vf = (ViewFlipper)findViewById(R.id.viewFlipper1);
txt1 = (TextView)findViewById(R.id.textView1);
txt1.setText(""+a);
txt2 = (TextView)findViewById(R.id.textView2);
txt2.setText(""+(a+1));
txt3 = (TextView)findViewById(R.id.textView3);
txt3.setText(""+(a-1));
btn1 = (Button)findViewById(R.id.left);
btn2 = (Button)findViewById(R.id.right);
btn1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Vf.showPrevious();
a-=1;
txt1.setText(""+(a));
txt2.setText(""+(a+1));
txt3.setText(""+(a-1));
}
});
btn2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Vf.showNext();
a+=1;
txt1.setText(""+(a));
txt2.setText(""+(a+1));
txt3.setText(""+(a-1));
}
});
}
}
////////////////
À§ÀÇ ¼Ò½º´Â ¼ýÀÚ°¡ ÃʱⰪ¿¡¼ °è¼Ó 2¾¿ Áõ°¨ÇÏ¸é¼ È¸éÀÌ ¹Ù²î´Â ¹æ½ÄÀÔ´Ï´Ù.
////////////////
/////////////////
main.xml
////////////////
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="
http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:weightSum="1">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/hello"
android:id="@+id/text" />
<ViewFlipper android:layout_height="wrap_content"
android:layout_width="match_parent" android:id="@+id/viewFlipper1"
android:layout_weight="0.71">
<LinearLayout android:id="@+id/linearLayout2"
android:background="#ffffff"
android:layout_width="match_parent" android:layout_height="match_parent"
android:orientation="vertical">
<TextView android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_height="wrap_content" android:id="@+id/textView1"
android:textColor="#000000"
android:text="TextView" android:layout_width="wrap_content"></TextView>
</LinearLayout>
<LinearLayout android:id="@+id/linearLayout3"
android:background="#ff0000"
android:layout_height="wrap_content" android:layout_width="match_parent"
android:orientation="vertical">
<TextView android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_height="wrap_content" android:id="@+id/textView2"
android:text="TextView" android:layout_width="wrap_content"></TextView>
</LinearLayout>
<LinearLayout android:id="@+id/linearLayout4"
android:background="#00ffff"
android:layout_width="match_parent" android:layout_height="match_parent"
android:orientation="vertical">
<TextView android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_height="wrap_content" android:id="@+id/textView3"
android:text="TextView" android:layout_width="wrap_content"></TextView>
</LinearLayout>
</ViewFlipper>
<LinearLayout android:id="@+id/linearLayout1"
android:layout_height="wrap_content" android:layout_width="match_parent">
<Button android:layout_height="wrap_content" android:text="Button"
android:id="@+id/left" android:layout_width="wrap_content"></Button>
<Button android:layout_height="wrap_content" android:text="Button"
android:id="@+id/right" android:layout_width="wrap_content"></Button>
</LinearLayout>
</LinearLayout>
////////////
ÀϺηΠ·¹À̾ƿô¿¡ »öÀ» Àâ¾Æ³ù´Âµ¥ ÀÌÀ¯´Â °¢·¹À̾ƿôÀÌ °ªº¯È¸¦ Á¦´ë·Î ¹ÞÀ¸¸é¼
·¹À̾ƿôÀüȯÀÌ ÀÌ·ç¾îÁö´Â°¡¸¦ È®ÀÎÇϱâ À§ÇÑ °ÍÀÔ´Ï´Ù.
////////////
* ±ÛÀ» µî·ÏÇϽǶ§ ²À ÇÊ¿äÇÑ °æ¿ì°¡ ¾Æ´Ï¸é °³ÀÎÁ¤º¸¸¦ ³²±âÁö ¸¶¼¼¿ä ^^ (¿¬¶ôó,À̸ÞÀÏÁÖ¼Ò,Áֹεî·Ï¹øÈ£ µî)