마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

뷰플리퍼와 페이지 슬라이딩 동시에 구현

0 추천
onCreate 메소드 아래에 동시에 구현하려 했는데
페이지 슬라이딩 기능을 추가하니 페이지 슬라이딩은 되고 뷰플리퍼가 안됩니다.
실력이 부족하여 이것저것 시도해 봐도 도저히 모르겠네요.. 도와주세요 ㅜㅜㅜ
코드는 다음과 같습니다.

package org.androidtown.ui.viewflipper;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.LinearLayout;

/**
 * ViewFlipper
 *
 * @author Mike
 */
public class SampleViewFlipperActivity extends Activity {
 
 ScreenViewFlipper flipper;
boolean isPageOpen = false;

   Animation translateLeftAnim;
   Animation translateRightAnim;

   LinearLayout slidingPage01;
   Button openBtn01;

    /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);

         // create a DataGridView instance
         ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
         flipper = new ScreenViewFlipper(this);

         setContentView(flipper, params);

        setContentView(R.layout.screenview);

        // Sliding Page
        slidingPage01 = (LinearLayout) findViewById(R.id.slidingPage01);

        translateLeftAnim = AnimationUtils.loadAnimation(this, R.anim.translate_left);
        translateRightAnim = AnimationUtils.loadAnimation(this, R.anim.translate_right);

        SlidingPageAnimationListener animListener = new SlidingPageAnimationListener();
        translateLeftAnim.setAnimationListener(animListener);
        translateRightAnim.setAnimationListener(animListener);

        // Open Button
        openBtn01 = (Button) findViewById(R.id.openBtn01);
        openBtn01.setOnClickListener(new OnClickListener() {
         public void onClick(View v) {

          // start animation
          if (isPageOpen) {
           slidingPage01.startAnimation(translateRightAnim);
          } else {
           slidingPage01.setVisibility(View.VISIBLE);
           slidingPage01.startAnimation(translateLeftAnim);
          }

         }
        });

    }

    private class SlidingPageAnimationListener implements AnimationListener {

  public void onAnimationEnd(Animation animation) {
   if (isPageOpen) {
    slidingPage01.setVisibility(View.INVISIBLE);

    openBtn01.setText("Open");
    isPageOpen = false;
   } else {
    openBtn01.setText("Close");
    isPageOpen = true;
   }
  }

  public void onAnimationRepeat(Animation animation) {

  }

  public void onAnimationStart(Animation animation) {

  }

    }

 
}
익명사용자 님이 2014년 4월 6일 질문

1개의 답변

+1 추천

setContentView 이거 왜 2개에요?

건방진프로그래머 (26,630 포인트) 님이 2014년 4월 7일 답변
...