开发者

Video Thumbnails

i want to show Video Thumbnails in GridView

private void initVideosId() {
        try
        {
            //Here we set up a string array of the thumbnail ID column we want to get back
            String [] proj={_ID};
          开发者_StackOverflow  // Now we create the cursor pointing to the external thumbnail store
            _cursor = managedQuery(_contentUri,
                    proj, // Which columns to return
                    null,       // WHERE clause; which rows to return (all rows)
                    null,       // WHERE clause selection arguments (none)
                    null); // Order-by clause (ascending by name)
            int count= _cursor.getCount();
            if(count==0)
                showToast("meiyou");
            // We now get the column index of the thumbnail id
            _columnIndex = _cursor.getColumnIndex(_ID);
            //initialize 
            _videosId = new int[count];
            //move position to first element
            _cursor.moveToFirst();          
            for(int i=0;i<count;i++)
            {           
                int id = _cursor.getInt(_columnIndex);
                //
                _videosId[i]= id;
                //
                _cursor.moveToNext();
                //
            }
        }catch(Exception ex)
        {
            showToast(ex.getMessage().toString());          
        }

    }
  public View getView(int position, View convertView, ViewGroup parent) 
    {
        ImageView imgVw= new ImageView(_context);;
        try
        {
            if(convertView!=null)
            {
                imgVw= (ImageView) convertView;
            }
            imgVw.setImageBitmap(getImage(_videosId[position]));
            imgVw.setAdjustViewBounds(true);
            imgVw.setBackgroundColor(Color.WHITE);
            imgVw.setLayoutParams(new Gallery.LayoutParams(150, 100));
            imgVw.setPadding(5,5,5,5);
            imgVw.setScaleType(ImageView.ScaleType.FIT_CENTER);
        }
        catch(Exception ex)
        {
            System.out.println("StartActivity:getView()-135: ex " + ex.getClass() +", "+ ex.getMessage());
        }
        return imgVw;
    }


private final static Uri MEDIA_EXTERNAL_CONTENT_URI = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
    private final static String _ID = MediaStore.Video.Media._ID;
    private final static String MEDIA_DATA = MediaStore.Video.Media.DATA;
but the result is : called showToast("meiyou");

i want to know if analog machine cannot have Video Thumbnails?if yes how to insert Video Thumbnails so that i can debug.anf give me::

ERROR/AndroidRuntime(290):java.lang.ClassCastException:android.widget.AbsListView$LayoutParams
ERROR/AndroidRuntime(290):at android.widget.Gallery.setUpChild(Gallery.java:769)
 ERROR/AndroidRuntime(290): at android.widget.Gallery.makeAndAddView(Gallery.java:738)
ERROR/AndroidRuntime(290):     at android.widget.Gallery.layout(Gallery.java:622)
ERROR/AndroidRuntime(290): at android.widget.Gallery.onLayout(Gallery.java:336)
 ERROR/AndroidRuntime(290):     at android.view.View.layout(View.java:7035)
ERROR/AndroidRuntime(290):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
 ERROR/AndroidRuntime(290):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
: ERROR/AndroidRuntime(290):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
: ERROR/AndroidRuntime(290):     at android.view.View.layout(View.java:7035)
 ERROR/AndroidRuntime(290):     at android.widget.FrameLayout.onLayout(FrameLayout.java:333)


change this line

   imgVw.setLayoutParams(new Gallery.LayoutParams(150, 100));

into this

  imgVw.setLayoutParams(new GridView.LayoutParams(150, 100));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜