0
大家好我想在我的應用程序中顯示圖像/視頻縮略圖。我使用以下代碼檢索縮略圖並將它們列在適配器中。 以下是代碼如何在android中顯示圖像/視頻縮略圖
public class ImageAdapter extends BaseAdapter {
private Context context;
private final String[] VideoValues;
public ImageAdapter(Context context, String[] VideoValues) {
this.context = context;
this.VideoValues = VideoValues;
}
public View getView(int position, View convertView, ViewGroup parent) {
System.out.println("***********In getView************");
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View gridView;
if (convertView == null) {
gridView = new View(context);
// get layout from gridlayout.xml
gridView = inflater.inflate(R.layout.gridlayout, null);
// set value into textview
TextView textView = (TextView) gridView
.findViewById(R.id.grid_item_label);
textView.setText(fileList[position]);
System.out.println("value of fileList[position]" + fileList[0]);
// set image
ImageView imageThumbnail = (ImageView) gridView
.findViewById(R.id.grid_item_image);
Bitmap bmThumbnail;
System.out
.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>> file path>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
+ fileList[position]);
bmThumbnail = ThumbnailUtils.createVideoThumbnail(FILE_PATH
+ fileList[position],
MediaStore.Video.Thumbnails.MINI_KIND);
if (bmThumbnail != null) {
System.out
.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>> THUMB NAIL>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
imageThumbnail.setImageBitmap(bmThumbnail);
} else {
System.out
.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>NO THUMB NAIL>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
}
} else {
gridView = (View) convertView;
}
return gridView;
}
public int getCount() {
// return 0;
return VideoValues.length;
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return 0;
}
}
}
它的圖像和視頻在三星Galaxy Tab 10.1做工精細,但它不是在此宏碁Iconia A501.any的思想工作。
兩者都在運行HoneyComb。
Rgds,
http://stackoverflow.com/q/9461283/1012284 – 2012-04-05 11:14:34
@Deva冷卻其確定。在4個問題中,他只得到2個答案。他比你好73%。 – 2012-04-05 11:16:29
這只是一個建議。沒有違法,但73%仍然比69%好。 – Deva 2012-04-05 11:25:05