Позвоните этому адаптеру из вашей активности
GridView view =(GridView) findViewbyId(is of grid view here);
view.setAdapter(new BottomMenuGridAdaptor(this.context));
Это код для адаптера
public class BottomMenuGridAdaptor extends BaseAdapter {
private Context context;
public BottomMenuGridAdaptor(Context context) {
super();
this.context = context;
}
@Override
public int getCount() {
return mThumbIds.length;
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null){
convertView = LayoutInflater.from(context).inflate(R.layout.tab_button, null);
}
LinearLayout ll=(LinearLayout) convertView.findViewById(R.id.linear_topbar);
if(position==PostionHandler.getPosition(context))
ll.setBackgroundResource(R.drawable.tab_blue_bg);
else
ll.setBackgroundResource(R.drawable.tab_red_bg);
ImageView imageView=(ImageView)convertView.findViewById(R.id.icon);
imageView.setImageResource(mThumbIds[position]);
TextView txt= (TextView) convertView.findViewById(R.id.title);
txt.setText(mThumbtext[position]);
return convertView;
}
private Integer[] mThumbIds = {
R.drawable.temp_thisweek,
R.drawable.temp_store,
R.drawable.temp_mylibrary,
R.drawable.temp_lateststore,
R.drawable.temp_more
};
private String[] mThumbtext = {
"This Week",
"C&EN Store",
"My Library",
"Latest News",
"More"
};