Hawkins
Hawkins

Reputation: 407

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)

Upvotes: 0

Views: 1871

Answers (1)

Robby Pond
Robby Pond

Reputation: 73484

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);
     ...
}

Upvotes: 4

Related Questions