gpt4 book ai didi

android - 视频缩略图

转载 作者:行者123 更新时间:2023-11-30 04:47:52 26 4
gpt4 key购买 nike

我想在 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};
// 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");

我想知道模拟机是否不能有视频缩略图?如果是如何插入视频缩略图以便我可以调试。anf 给我::

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)

最佳答案

改变这一行

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

进入这个

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

关于android - 视频缩略图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4397163/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com