I have a grid view that have 8 images
Now on a particular image view i want to set a text value that will be changed dynamically
Main XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/mainLinearLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@drawable/blue_bar"
android:orientation="horizontal" >
</LinearLayout>
<GridView
android:id="@+id/gridView1"
android:layout_below="@+id/mainLinearLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="20dp"
android:columnWidth="100dp"
android:gravity="center"
android:numColumns="2"
android:stretchMode="columnWidth" >
</GridView>
</RelativeLayout>
**Inner XML Layout **
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp" >
<ImageView
android:id="@+id/grid_item_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="10dp"
android:src="@drawable/ic_launcher" />
</LinearLayout>
Code Main Activity
gridView = (GridView) findViewById(R.id.gridView1);
gridView.setAdapter(new ImageAdapter(this, DASHBOARD_LINKS));
Adapter Class
public class ImageAdapter extends BaseAdapter {
private Context context;
private final String[] dashBoardValues;
public ImageAdapter(Context context, String[] dashBoardValues) {
this.context = context;
this.dashBoardValues = dashBoardValues;
}
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View gridView;
if (convertView == null) {
gridView = new View(context);
// get layout from dashboard_inner.xml
gridView = inflater.inflate(R.layout.dashboard_inner, null);
// set image based on selected text
ImageView imageView = (ImageView) gridView
.findViewById(R.id.grid_item_image);
imageView.setImageResource(R.drawable.ic);
} else {
gridView = (View) convertView;
}
return gridView;
}
@Override
public int getCount() {
return dashBoardValues.length;
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
}
So how could i do this in a grid view .Please help me .