Android - gridview-scrolling-Problem (sehr langsamer scroll)

Es ist meine erste app, also ich bin nicht verwenden, um code auf java.

Ich habe ein gridview welches Sie Miniaturansichten von der sdcard, aber ich kann nicht haben eine glatte scrollen.

Wenn ich die /* - Behandlung-Teil*/aus der, wenn das scrollen wie ich will, aber Sie sind duplicate content und ein Teil der Bilder nicht angezeigt.

Hier ist mein code:

Handlung:

        GridView gridview = (GridView) findViewById(R.id.gridview1);
     String[] projection = {MediaStore.Images.Media._ID};
     String path ="/mnt/sdcard/Pictures";
     //Create the cursor pointing to the SDCard
     cursor = managedQuery( MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
             projection, 
             //MediaStore.Images.Media.DATA + " like ? ",
             //new String[] {"%Pictures%Sopi%"},  
             "_data LIKE '%" + path  + "/%'",                
             null,
             MediaStore.Images.Media._ID);

    //Get the column index of the Media Image ID
    columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media._ID);

    gridview.setAdapter(new ImageAdapterTest(RoomRawActivity.this));

-imageAdapater (anzeigen):

public View getView(int position, View convertView, ViewGroup parent) {

    Log.v("adapter - getView","getView start!!");
    //Toast.makeText(mContext, "getView start!!"+position, 0).show();

    //Move cursor to current position
    RoomRawActivity.cursor.moveToPosition(position);

    ImageView picturesView;

    if (convertView == null) {

        picturesView = new ImageView(mContext);

            /* treatment */

//Get the current value for the requested column
int imageID = RoomRawActivity.cursor.getInt(RoomRawActivity.columnIndex);
//obtain the image URI
Uri uri = Uri.withAppendedPath( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, Integer.toString(imageID) );
String url = uri.toString();

//Set the content of the image based on the image URI
int originalImageId = Integer.parseInt(url.substring(url.lastIndexOf("/") + 1,   url.length()));
Bitmap b = MediaStore.Images.Thumbnails.getThumbnail(mContext.getContentResolver(),
         originalImageId, 
         MediaStore.Images.Thumbnails.MINI_KIND, 
         null);
        picturesView.setPadding(5, 5, 5, 5);
        picturesView.setBackgroundResource(R.drawable.border_grid_pics);

        picturesView.setImageBitmap(b);

        picturesView.setScaleType(ImageView.ScaleType.FIT_XY);
            /* END  treatment */
        }
    }else{
        picturesView = (ImageView) convertView;   
    }



    return picturesView;
}

Vielen Dank!
David.

  • Wenn ich MINI_KIND von MICRO_KIND das scrollen ist glatt, aber alle Bilder haben die gleiche Größe (ich möchte Portraits und Landschaft Daumen).
InformationsquelleAutor David.C | 2012-03-13
Schreibe einen Kommentar