public class Video_activity extends Activity implements OnTouchListener{
//private String values[] = {"SHINee - Sherlock", "SHINee - EveryBody", "SHINee - Colorful"};
int imageIndex = 0;
ImageButton vimage1;
ImageButton vimage2;
ImageButton vimage3;
TextView name;
ViewFlipper flipper;
float xAtDown;
float xAtUp;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video_layout);
//이미지뷰
vimage1 = (ImageButton)findViewById(R.id.sherimage);
vimage2 = (ImageButton)findViewById(R.id.bodyimage);
vimage3 = (ImageButton)findViewById(R.id.colorimage);
//텍스트뷰
name = (TextView)findViewById(R.id.videoinfo);
//filpper등록
flipper = (ViewFlipper) findViewById(R.id.flipper);
flipper.setOnTouchListener(this);
vimage1.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Intent intent = new Intent(Video_activity.this, VideoPage.class);
startActivity(intent);
return true;
}
});
}
@Override
public boolean onTouch(View v, MotionEvent event) {
// 터치 이벤트가 일어난 뷰가 ViewFlipper가 아니면 return
if(v != flipper) return false;
if(event.getAction() == MotionEvent.ACTION_DOWN) {
xAtDown = event.getX(); // 터치 시작지점 x좌표 저장
}
else if(event.getAction() == MotionEvent.ACTION_UP){
xAtUp = event.getX(); // 터치 끝난지점 x좌표 저장
if( xAtUp < xAtDown ) {
// 왼쪽 방향 에니메이션 지정
flipper.setInAnimation(AnimationUtils.loadAnimation(this,R.anim.push_left_in));
flipper.setOutAnimation(AnimationUtils.loadAnimation(this,R.anim.push_left_out));
// 다음 view 보여줌
flipper.showNext();
}
else if (xAtUp > xAtDown){
// 오른쪽 방향 에니메이션 지정
flipper.setInAnimation(AnimationUtils.loadAnimation(this,R.anim.push_right_in));
flipper.setOutAnimation(AnimationUtils.loadAnimation(this,R.anim.push_right_out));
// 전 view 보여줌
flipper.showPrevious();
}
}
return false;
}
}
제가 하려는건 일단 뮤직비디오를 볼 수 있는 어플입니다.....
생각했던 그림은 뷰플리퍼를 이용해서 앨범 커버를 넘기고, 그 커버를 선택했을 때 뮤비가 재생이 되게 하려고 했습니다.
그래서 뷰 플리퍼 안에 이미지들을 넣었습니다. 이미지들을 넣을때 이미지 뷰어가 아니라 이미지 버튼으로 했습니다.
뷰플리퍼 넘길 때 사용하는 이벤트는 touch이구요, 선택할때는 longclick을 하려고 했습니다.
touch까지는 잘 됐는데 버튼 longclick을 집어 넣으니깐.. 그때부터 클릭만 되고 터치가 되지 않네요 ㅜㅜ
왜그럴까요...................