直播平台源代码,显示相册内图片的缩略图相关代码
String queryImageThumbnailPathByID(int ID) { Uri uri = MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI; String[]projection = new String[]{ MediaStore.Images.Thumbnails.DATA }; String selection = MediaStore.Images.Thumbnails.IMAGE_ID + " = ?"; String[] selectionArgs = new String[]{ String.valueOf(ID) }; Cursor cursor = getContentResolver().query(uri, projection, selection, selectionArgs, null); String thumbnail_path = ""; if (cursor.moveToFirst()) { thumbnail_path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Thumbnails.DATA)); } cursor.close(); return thumbnail_path; } String[] projection = new String[]{ MediaStore.Images.Media.DATA, MediaStore.Images.Media.DATE_MODIFIED, MediaStore.Images.Media.SIZE, MediaStore.Images.Media._ID }; Cursor cursor = getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null, null, MediaStore.Images.Media.DATE_MODIFIED + " DESC"); ListView listView = new ListView(this); SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.item, cursor, new String[]{ MediaStore.Images.Media.DATA, MediaStore.Images.Media.DATA, MediaStore.Images.Media.SIZE, MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID }, new int[]{ R.id.textView_path, R.id.textView_name, R.id.textView_size, R.id.textView_time, R.id.imageView_icon }, CursorAdapter.FLAG_AUTO_REQUERY); adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() { public boolean setViewValue(View view, Cursor cursor, int columnIndex) { ...... if (view.getId() == R.id.imageView_icon) { int ID = cursor.getInt(columnIndex); //((ImageView)view).setImageURI(Uri.fromFile(new File(queryVideoThumbnailPathByID(ID)))); Bitmap bitmap = MediaStore.Images.Thumbnails.getThumbnail(getContentResolver(), ID, MediaStore.Images.Thumbnails.MINI_KIND, null); ((ImageView) view).setImageBitmap(bitmap); } } }
以上就是 直播平台源代码,显示相册内图片的缩略图相关代码,更多内容欢迎关注之后的文章