public class GridViewVideoAdapter extends BaseAdapter{
private Context context;
private Integer[] imgs = {
R.drawable.huifang,R.drawable.shang,R.drawable.shishi,
R.drawable.zuo,R.drawable.play,R.drawable.you,
R.drawable.liebiao,R.drawable.xia
};
public GridViewVideoAdapter(Context context){
this.context = context;
}
public int getCount() {
return imgs.length;
}
public Object getItem(int item) {
return item;
}
public long getItemId(int id) {
return id;
}
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) {
imageView = new ImageView(context);
imageView.setLayoutParams(new GridView.LayoutParams(110, 110));
imageView.setAdjustViewBounds(false);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(5, 5, 5, 5);
}
else {
imageView = (ImageView) convertView;
}
imageView.setImageResource(imgs[position]);
imageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Log.e("imageview", arg0.toString());
}
});
return imageView;
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android1="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android1:layout_width="match_parent"
android1:layout_height="wrap_content"
android1:layout_weight="0.62"
android1:orientation="vertical" >
<VideoView
android1:id="@+id/video_view"
android1:layout_width="match_parent"
android1:layout_height="340dp" />
<GridView
android:id="@+id/gridview1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="#FFeff1ef"
android:gravity="center"
android:horizontalSpacing="10dp"
android:numColumns="3"
android:verticalSpacing="10dp" />
</LinearLayout>
</LinearLayout>
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。