2010-12-28 6 views
1

ich möchte, dass meine Bilder vom ersten zum letzten verschoben werden müssen, aber es werden nur die letzten Bilder angezeigt, die ich hinzufügen möchte, um alle Bilder in der Animation anzuzeigen package com.viewslide;Android Timer in der Diashow

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); 
     } 
    } 
} 

Antwort

0

Ich denke, man folgendes vor der Schleife sollte hinzufügen:

startManagingCursor(cursor); 

cursor.movetofirst();