0
即時得到在我的代碼nullPointerException
這是我的adapter
如何設置位圖網格視圖
public class ImageAdapter extends BaseAdapter {
private Context mContext;
private Bitmap btimaprecieve;
public ImageAdapter(Context c) {
mContext = c;
}
public int getCount() {
return mThumbIds.length;
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return 0;
}
// create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) { // if it's not recycled, initialize some
// attributes
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(8, 8, 8, 8);
} else {
imageView = (ImageView) convertView;
}
imageView.setImageResource(mThumbIds[position]);
return imageView;
}
private Integer[] mThumbIds = { R.drawable.sample_pic,
R.drawable.sample_pic, R.drawable.sample_pict,
R.drawable.sample_pict, R.drawable.sample_pic, };
public Bitmap add(Bitmap bitmap_recieve) {
return btimaprecieve;
}
}
這是我的主要活動,其中我提到的GridView
myImageAdapter= new ImageAdapter(this);
gridview.setAdapter(myImageAdapter);
myImageAdapter.add(Bitmap_recieve);
過去的日誌貓在哪兒買例外 – Nand
首先格式的代碼.. –