i’m developing an app for android and want using GridView build a menu with icons. For this I used already existing solution by http://www.edumobile.org/android/android-beginner-tutorials/draw-menu-in-grid-view/, but the in result the system shows that mThumbIds – cannot be resolved to a variable, when i try to declare it as an new local variable, the error is still existing. i’m new in android and maybe making very simple mistake, but i can’t solve it by myself. So, any suggestions would be helpful. Here is the code:
public class ImageAdapter extends BaseAdapter {
public ImageAdapter(Context c) {
mContext = c;
}
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 imageView;
if (convertView == null) {
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(45, 45));
imageView.setAdjustViewBounds(false);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(8, 8, 8, 8);
} else {
imageView = (ImageView) convertView;
}
imageView.setImageResource(mThumbIds[position]);
return imageView;
}
private Context mContext;
private Integer[] mThumIbs = {
R.drawable.ic_cards, R.drawable.ic_bank,
R.drawable.ic_currency, R.drawable.ic_calc,
R.drawable.ic_banking, R.drawable.ic_call,
};
}
You have a typo:
Instead of mThumbIbs, shouldn’t this be mThumbIds?