幻灯片中的Android计时器

时间:2010-12-28 05:16:29

标签: android android-layout

我希望我的图片必须从头到尾移动,但它只显示我想要添加计时器的最后图像以查看动画中的所有图像 package com.viewslide;

import android.app.Activity;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

public class slideview extends Activity {
    private Animation slideLeftOut;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        String[] filePathColumn = {MediaStore.Images.Media.DATA};
        Cursor cursor = getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, filePathColumn, null, null, null);
        int count= cursor.getCount();
        int i;
        for(i=0; i<6; i++) {
            cursor.moveToPosition(i);
            int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
            String filePath = cursor.getString(columnIndex);
            cursor.close();
            Bitmap yourSelectedImage = BitmapFactory.decodeFile(filePath);
            ImageView img1= (ImageView)findViewById(R.id.img1);

            img1.setImageBitmap(yourSelectedImage);
            slideLeftOut = AnimationUtils.loadAnimation(this, R.anim.hyperspace_jump);
            img1.startAnimation(slideLeftOut);
        }
    }
}

1 个答案:

答案 0 :(得分:0)

我想你应该在循环之前添加以下内容:

startManagingCursor(cursor);

cursor.movetofirst();