http://snowbora.com/404 이 블로거를 참조해서 ViewFlipper를 만들었습니다.

응용으로 제가 탭에다가 적용 하려고 하였는데

맨처음 탭만 ViewFlipper가 작동되고 다른 탭에서는 적용이 안되네요 

소스는 첨부합니다.]

보시기 짜증나시더라고 ㅠ 부탁드립니다;


ImageView image;

TabHost mTabHost;

ViewFlipper m_viewFlipper;

int m_nPreTouchPosX = 0;


    mTabHost=getTabHost();

        mTabHost.addTab(mTabHost.newTabSpec("tab1").setContent(R.id.tabs1).setIndicator("사진촬영"));

        mTabHost.addTab(mTabHost.newTabSpec("tab2").setContent(R.id.tabs2).setIndicator("사진선택"));

        mTabHost.addTab(mTabHost.newTabSpec("tab3").setContent(R.id.tabs3).setIndicator("스티커제작"));

   

        m_viewFlipper = (ViewFlipper)findViewById(R.id.viewFlipper);

        m_viewFlipper.setOnTouchListener(MyTouchListener);

}

private void MoveNextView()

    {

    m_viewFlipper.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.appear_from_right));

    m_viewFlipper.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.disappear_from_left));

    m_viewFlipper.showNext();

    }

    private void MovePreviousView()

    {

    m_viewFlipper.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.appear_from_left));

    m_viewFlipper.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.disappear_from_right));

    m_viewFlipper.showPrevious();

    }

    OnTouchListener MyTouchListener = new View.OnTouchListener() {


@Override

public boolean onTouch(View v, MotionEvent event) {

// TODO Auto-generated method stub

if(event.getAction() == MotionEvent.ACTION_DOWN)

{

m_nPreTouchPosX = (int)event.getX();

}

if(event.getAction() == MotionEvent.ACTION_UP)

{

int nTouchPosX = (int)event.getX();

if(nTouchPosX < m_nPreTouchPosX)

{

MoveNextView();

}

else if(nTouchPosX > m_nPreTouchPosX)

{

MovePreviousView();

}

m_nPreTouchPosX = nTouchPosX;

}

return true;

}

    };


탭과 ViewFlipper을 지정하였습니다. 탭이 3개인데 ViewFlipper을 같이 사용해도 될것같아서 하나만 해서 id을 동일하게 적용했습니다.

xml소스입니다.

<?xml version="1.0" encoding="utf-8"?>    

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:id="@android:id/tabhost">

    

    <LinearLayout 

        android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical">

        

        <TabWidget 

            android:layout_width="fill_parent"

    android:layout_height="wrap_content"

    android:id="@android:id/tabs" />

        

        <FrameLayout 

             android:layout_width="match_parent"

     android:layout_height="match_parent"

     android:id="@android:id/tabcontent" >

    

    <LinearLayout 

                android:id="@+id/tabs1"

                android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical">

     <ViewFlipper 

        android:id="@+id/viewFlipper"

        android:layout_width="fill_parent"

        android:layout_height="fill_parent"

        >

    <ImageView

        android:id="@+id/iview"

        android:layout_width="fill_parent"

        android:layout_height="fill_parent"

      android:background="@drawable/help_detail"/>    

    <Button 

        android:id="@+id/bt"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"/>

    </ViewFlipper>

           </LinearLayout>  

               

<LinearLayout 

                android:id="@+id/tabs2"

                android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical">

      <ViewFlipper 

        android:id="@+id/viewFlipper"

        android:layout_width="fill_parent"

        android:layout_height="fill_parent"

        >

    <ImageView

        android:id="@+id/iview"

        android:layout_width="fill_parent"

        android:layout_height="fill_parent"

      android:background="@drawable/help_detail"/>    

    <Button 

        android:id="@+id/bt"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"/>

    <TextView 

                android:layout_width="fill_parent"

    android:layout_height="wrap_content"

    android:id="@+id/tv" 

    android:text="Tab2"/>

    </ViewFlipper>

           </LinearLayout>            

            

            <LinearLayout 

                android:id="@+id/tabs3"

                android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical">

     <ViewFlipper 

        android:id="@+id/viewFlipper"

        android:layout_width="fill_parent"

        android:layout_height="fill_parent"

        >

    <EditText 

                android:layout_width="wrap_content"

    android:layout_height="fill_parent"

    android:hint="EditText"/>

    <RatingBar 

        android:layout_width="wrap_content"

    android:layout_height="wrap_content"/>

    </ViewFlipper>

           </LinearLayout>    

        </FrameLayout>

    </LinearLayout>

</TabHost>