点击改变背景色怎么实现
Opened this issue · 2 comments
点击改变背景色怎么实现
怎样改变背景颜色呀
看到有人不会改变这标签的背景色,或许我写的下面的代码能够帮助到你~
TagCloudLayout selectTags;
selectTags.setItemClickListener(new TagCloudLayout.TagItemClickListener() {
@OverRide
public void itemClick(int position) {
//判断集合中是否有选中的标签,有则移除,没有则添加。并改变字体的颜色
TextView tagsText = (TextView) selectTags.getChildAt(position);
if (tagsText.getCurrentTextColor() == getResources().getColor(R.color.red_FF3688)) {
for (int i = 0; i < mSubmitTagsList.size(); i++) {
if (mSubmitTagsList.get(i).contains(tagsList.get(position).getId() + ",")) {
mSubmitTagsList.remove(i);
}
}
tagsText.setTextColor(getResources().getColor(R.color.black_606060));
} else {
tagsText.setTextColor(getResources().getColor(R.color.red_FF3688));
mSubmitTagsList.add(tagsList.get(position).getId() + ",");
}
}
});