0

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;

            }
        }
    }
mkj
  • 2,761
  • 5
  • 24
  • 28
balaji
  • 1,555
  • 5
  • 26
  • 49

1 Answers1

0

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

Community
  • 1
  • 1
jbowes
  • 4,062
  • 22
  • 38