Hawkins Hawkins - 1 year ago 104
Android Question

Custom adapter in GridView

I try to do some calendar. I do it as GridView with custom adapter.
How in adapter combine 2 TextView(date and text) and icons (red circle) ?

(screen for example)

Answer Source

You must create a layout(with an ImageView for the icon and 2 TextViews) for each item and inflate the layout into a view in the getView() method of your adapter. Something like

View getView(int position, View convertView, ViewGroup parent) {
     if(convertView == null) { // recycled view is null so create it.
          convertView = View.inflate(context, R.id.layout, parent);
     ImageView imageView = convertView.findViewById(R.id.image);
     TextView tv1 = convertView.findViewById(R.id.text1);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download