Gallery 的 Demo(2)
来源:未知 责任编辑:责任编辑 发表时间:2013-12-18 11:34 点击:次
Toast.makeText(_Gallery.this, String.valueOf(position), Toast.LENGTH_SHORT).show();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});
}
// 继承 BaseAdapter 用以实现自定义的图片适配器
public class ImageAdapter extends BaseAdapter {
private Context mContext;
public ImageAdapter(Context context) {
mContext = context;
}
public int getCount() {
return mThumbIds.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
ImageView image = new ImageView(mContext);
image.setImageResource(mThumbIds[position]);
image.setAdjustViewBounds(true);
image.setLayoutParams(new Gallery.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
return image;
}
}
// 需要显示的图片集合
相关新闻>>
- 发表评论
-
- 最新评论 更多>>