@@ Branislav-I did same as you have said.and it worked for me but when no of images exceeded to 9 n text also it started showing me same 1st or ant random image and text at the place of 9th image and text
public class ImageAdapter extends BaseAdapter {
private Context mContext;
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) {
View v;
if (convertView == null) { // if it's not recycled, initialize some attributes
LayoutInflater li = getLayoutInflater();
v = li.inflate(R.layout.mainmenu, null);
TextView tv = (TextView)v.findViewById(R.id.icon_text);
tv.setText(mTextsIds[position]);
ImageView iv = (ImageView)v.findViewById(R.id.icon_image);
iv.setImageResource(mThumbIds[position]);
} else {
v = (View) convertView;
}
return v;
}
private Integer[] mThumbIds = {
R.drawable.hotel1, R.drawable.rest,R.drawable.dubaicityinfoicon_new,R.drawable.history1,R.drawable.geography,R.drawable.infoicon,R.drawable.infoicon,R.drawable.infoicon,R.drawable.parkmain,
};
// references to our texts
private String[] mTextsIds = {
"Hotels","Restaurants","City Info","Dubai History","Geography Of Dubai","Useful Information","Embassies in Duabai","Museum's","park"
};
In this it’s going perfect till museum but for park it’s not working; it is showing any random image and associated text within the array mThumbIds. And yes, the image is available in drawable.
You can make custome adapter class for that
and call that this way
Where mDatas is