开发者

Custom adapter in GridView

I try to do some calendar. I do it as GridView with custom adapter. How in adapter combine 2 TextView(d开发者_如何学运维ate and text) and icons (red circle) ?

(screen for example)


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜