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) {
}
}
}