在listview监听中设置后
item_text = (TextView) parent.getChildAt(position).findViewById(R.id.listtext);
item_text.setTextColor(Color.YELLOW);
发现点击后textview变色的文字会随着列表滑动 任意分配位置 求解决
在listview监听中设置后
item_text = (TextView) parent.getChildAt(position).findViewById(R.id.listtext);
item_text.setTextColor(Color.YELLOW);
发现点击后textview变色的文字会随着列表滑动 任意分配位置 求解决
在类中声明一个成员
private List clickedItems = new ArrayList<>();
在listview的listener中,当item被点击了,把item所 在的position加入到clickedItem中
clickedItems.add(position);
//在getView中
getView(....){
//...
item_text = (TextView) parent.getChildAt(position).findViewById(R.id.listtext);
if(clickedItems.contains(position)){
item_text.setTextColor(Color.YELLOW);
}else{
item_text.setTextColor(Color.BLACK);
}
}
//...}
以上是大概的思路。