Today, we had to give the app to the client for testing at their side. So, the last thing which I was assigned was to design the dashboard for the app.
I used grid view for that purpose.
<GridView
android:id="@+id/gridView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:columnWidth="90dp"
android:numColumns="2"
android:stretchMode="columnWidth"
android:listSelector="@android:color/transparent"
android:gravity="center"/>
Calling the adapter class, which is a subclass of BaseAdapter , for inflating the views :
gridView=(GridView)findViewById(R.id.gridView);
gridView.setAdapter(new GridViewAdapter(this, list, img));
GridViewAdapter’s getView method :
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View rowView;
LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
rowView=inflater.inflate(R.layout.grid_item_layout,null);
ImageView imgs=(ImageView)rowView.findViewById(R.id.imageViewItem);
TextView txt=(TextView)rowView.findViewById(R.id.textViewItem);
txt.setText(nameList[position]);
imgs.setImageResource(img[position]);
return rowView;
}