今はスライドを使用してフリップビューを表示できます。私は5秒後に自動的にビューを反転させたい。自動フリップ付きビューフリッパーについて
私はジェスチャー認識に基づいてビューを反転しなければならないコードは次のとおりです。
class MyGestureDetector extends SimpleOnGestureListener {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
try {
if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH)
return false;
// right to left swipe
if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE
&& Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
viewFlipper.setInAnimation(slideLeftIn);
viewFlipper.setOutAnimation(slideLeftOut);
if (currentIndex == maxIndex) {
currentIndex = 0;
} else {
currentIndex = currentIndex + 1;
}
if (currentView == 0) {
currentView = 1;
ImageView iv = (ImageView) findViewById(R.id.one);
/*iv.setImageDrawable(Drawable.createFromPath(ImageList
.get(currentIndex)));*/
Bitmap mBitmap=BitmapFactory.decodeFile(ImageList.get(currentIndex));
iv.setImageBitmap(mBitmap);
Log.d("image list index!!", ImageList.get(currentIndex));
System.gc();
} else if (currentView == 1) {
currentView = 2;
ImageView iv = (ImageView) findViewById(R.id.two);
/*iv.setImageDrawable(Drawable.createFromPath(ImageList
.get(currentIndex)));*/
Bitmap mBitmap=BitmapFactory.decodeFile(ImageList.get(currentIndex));
iv.setImageBitmap(mBitmap);
Log.d("image list index!!", ImageList.get(currentIndex));
System.gc();
} else {
currentView = 0;
ImageView iv = (ImageView) findViewById(R.id.zero);
/*iv.setImageDrawable(Drawable.createFromPath(ImageList
.get(currentIndex)));
*/
Bitmap mBitmap=BitmapFactory.decodeFile(ImageList.get(currentIndex));
iv.setImageBitmap(mBitmap);
Log.d("image list index!!", ImageList.get(currentIndex));
System.gc();
}
Log.v("ImageViewFlipper", "Current View: " + currentView);
viewFlipper.showNext();
viewFlipper.startFlipping();
} else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE
&& Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
viewFlipper.setInAnimation(slideRightIn);
viewFlipper.setOutAnimation(slideRightOut);
if (currentIndex == 0) {
currentIndex = maxIndex;
} else {
currentIndex = currentIndex - 1;
}
if (currentView == 0) {
currentView = 2;
ImageView iv = (ImageView) findViewById(R.id.two);
iv.setImageDrawable(Drawable.createFromPath(ImageList
.get(currentIndex)));
System.gc();
} else if (currentView == 2) {
currentView = 1;
ImageView iv = (ImageView) findViewById(R.id.one);
iv.setImageDrawable(Drawable.createFromPath(ImageList
.get(currentIndex)));
System.gc();
} else {
currentView = 0;
ImageView iv = (ImageView) findViewById(R.id.zero);
iv.setImageDrawable(Drawable.createFromPath(ImageList
.get(currentIndex)));
System.gc();
}
Log.v("ImageViewFlipper", "Current View: " + currentView);
viewFlipper.showPrevious();
}
} catch (Exception e) {
// nothing
}
return false;
}
}
私は今viewFlipper.showNext()を使用してめくるとshowPrevious()メソッドいます。 I)は(
viewFlipper.setFlipInterval(1000);
とviewFlipper.startFlippingを使用してみました。 メソッド。私が今直面している問題は、3つの画像ビューが連続して連続してロードする必要があることです(画像が移動するにつれて画像がそれぞれ変化する)。これは起こっていない。私は2つの固定画像しか見ることができず、内容を変更することなく次々と表示しています。この問題をどうやって解決するのですか?
を助け上記link.hopeに従ってください分後。新しい問題。私は上記のコードを変更して、画像をviewflipperに動的に追加しました。アプリはメモリの問題のために強制終了しています..どのような回避策ですか? – user838522