I try onGestureListener interface.
I prepare GestureDetector.
mGestureDetector = new GestureDetector(this, this);I input onTouchEvent parameter.
public boolean onTouchEvent(MotionEvent ev) { mGestureDetector.onTouchEvent(ev); return false; }I prepare onFling at onGestureListener.
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {If velocityY smaller than 0, next page.
if (velocityY < 0) {//right mPagenumber++;If velocityY bigger than 0, prev page.
}else {//left mPagenumber--;select image from Resource. I prepare image name "sxxx.jpg". xxx is number. exsapme s001.jpg, s002.jpg, s003.jpg....s020.jpg...
I set selected image to view.
Resources res = getResources(); int resid = res.getIdentifier(filename, "drawable", getPackageName()); ImageView img = (ImageView)findViewById(R.id.imageView1); img.setImageResource(resid);source code is here. Please suggest your android issue by twitter or mail, I would try to clear up your issue.
0 件のコメント:
コメントを投稿