gpt4 book ai didi

android gridview+baseadapter+scroll 在背景中设置图像的问题?

转载 作者:行者123 更新时间:2023-11-29 21:58:53 25 4
gpt4 key购买 nike

我正在使用 gridview 来显示 7 列和 96 行。当我点击特定的单元格时,它应该用不同的图像突出显示。该单元格用差异图像突出显示,但是当我滚动 gridview 时,多个单元格用该图像突出显示,而不是单个选定的单元格。这是我的适配器类的一段代码。

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

最佳答案

解决了

if ((rangeList != null && rangeList.size() > 0)
&& (rangeList.contains(position))) {
txtgridcell
.setBackgroundResource(R.drawable.item_background_focused);
} else {
txtgridcell.setBackgroundResource(R.drawable.item_background);
}

添加其他条件解决了我的问题。

关于android gridview+baseadapter+scroll 在背景中设置图像的问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12450437/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com