开发者

Android timer in slideshow

i want my images must move from first to last but it only shows the last images i want to add timer to view all the images in animation 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 whe开发者_C百科n 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);
        }
    }
}


I guess you should add the following before the loop:

startManagingCursor(cursor);

cursor.movetofirst();

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜