1
我正在使用gridview来显示7colums和96rows。当我点击特定的单元格时,它应该用不同的图像突出显示。该单元格突出显示diff图像,但当我滚动gridview多个单元格突出显示该图像,而不是单个选定的单元格。 这是我的适配器类的一段代码。android gridview + baseadapter +滚动问题设置图像背景?
public View getView(int position, View convertView, ViewGroup parent) {
TextView txtgridcell = null;
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(
R.layout.gridview_row, null);
}
txtgridcell = (TextView) convertView.findViewById(R.id.txtgridcell);
**if ((rangeList != null && rangeList.size() > 0)
&& (rangeList.contains(position))) {
txtgridcell
.setBackgroundResource(R.drawable.item_background_focused);
}**
我不确定问题是什么,但是你还没有发布完整的代码 - “getView(...)'应该返回一个代码没有包含的'View'。 – Squonk
有这种问题的人吗? – Hitendra