balaji balaji - 1 month ago 8
Android Question

how to solve my video thumbnails? nothing display in my emulator screen

I am trying to display my video thumbnails, but my emulator displays an empty screen. I don't know where I'm making a mistake. I am trying to show these video thumbnails in my tab host.

This is my code:

public class video extends Activity {
//set constants for MediaStore to query, and show videos

//flag for which one is used for images selection
private GridView _gallery;



/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.mavideo);
//set GridView for gallery
_gallery = (GridView)findViewById(R.id.sdcard);
//set default as external/sdcard uri


//set gallery adapter
setGalleryAdapter();
}
private void setGalleryAdapter() {
_gallery.setAdapter(new VideoGalleryAdapter(this));
}

//
private class VideoGalleryAdapter extends BaseAdapter {

private Context mContext;

public VideoGalleryAdapter(Context c) {
mContext = c;
}

public int getCount() {
return tabview.videoList.size();
}

public Object getItem(int position) {
return null;
}

public long getItemId(int position) {
return 0;
}
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) { // if it's not recycled, initialize some attributes
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(8, 8, 8, 8);
} else {
imageView = (ImageView) convertView;
}


Bitmap bitmap = BitmapFactory.decodeFile(tabview.videoList.get(position));
imageView.setImageBitmap(bitmap);
return imageView;

}
}
}

Answer

What is tabview.videoList? you might be getting null bitmaps from BitmapFactory.decodeFile, which is why you wouldn't see anything. http://stackoverflow.com/a/2349063/1205715 has a good description of how to get video thumbnails.