我有一个数组中的url字符串。如何在gridview中显示视频的网址,并点击下一个屏幕中的网格播放。 如何实现这个?任何一个指导我..如何使用视频网址字符串在网格视图中显示视频
我试过像其作品fine..How实现对视频,阵列是string..url ..
public class act extends Activity {
/** Called when the activity is first created. */
//Integer[] imageIDs={R.drawable.icon,R.drawable.icon,R.drawable.icon};
String uri1="https://i3.ytimg.com/vi/bQaWsVQSLdY/default.jpg";
String uri2="https://i4.ytimg.com/vi/cJQCniWQdno/mqdefault.jpg";
String uri3="https://i1.ytimg.com/vi/D8dA4pE5hEY/mqdefault.jpg";
String[] urls={uri1,uri2,uri3};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
GridView grd=(GridView)findViewById(R.id.gridView1);
grd.setAdapter(new ImageAdapter(this));
grd.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent,View v,int pos,long id)
{
Toast.makeText(getBaseContext(),"pic"+(pos+1)+"select ",Toast.LENGTH_SHORT).show();
}
});
}
public class ImageAdapter extends BaseAdapter
{
private Context context;
private int itemBackground;
ImageAdapter(Context c)
{
context=c;
TypedArray a=obtainStyledAttributes(R.styleable.Gallery1);
itemBackground=a.getResourceId(R.styleable.Gallery1_android_galleryItemBackground,0);
a.recycle();
}
public int getCount()
{
return urls.length;
}
public Object getItem(int pos)
{
return pos;
}
public long getItemId(int pos)
{
return pos;
}
public View getView(int pos,View cv,ViewGroup vg)
{
ImageView imageview=new ImageView(context);
imageview.setImageResource(urls.length);
imageview.setScaleType(ImageView.ScaleType.FIT_XY);
imageview.setLayoutParams(new GridView.LayoutParams(150,120));
imageview.setBackgroundResource(itemBackground);
return imageview;
}
}
}
非常感谢提前....
视频快到形式在哪里?自己的服务器或YouTube? – 2013-04-25 05:54:05
将youtube链接存储在服务器中,其来自服务器 – 2013-04-25 06:01:01
,那么youtube会为您提供该视频的缩略图。你为什么不想显示文本? – 2013-04-25 06:13:06