单击我的项目时,我正在排序,但是排序后,收藏夹图标的填充色未设置或消失,这就是我正在做的事情
@Override
public void onBindViewHolder(@NonNull final LineViewHolder holder, final int position) {
final Line line = lines.get(position);
holder.line_name.setText(line.getName());
holder.favorite.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!Utils.userLogged()) {
showLoginInviteDialog();
} else {
if (!line.isFavorite()) {
holder.favoriteFilled.setVisibility(View.VISIBLE);
line.setIsfavorite(true);
//order
Collections.sort(lines, new LineComparator());
notifyDataSetChanged();
} else {
holder.favoriteFilled.setVisibility(View.GONE);
line.setIsfavorite(false);
Collections.sort(lines, new LineComparator());
notifyDataSetChanged();
}
}
}
});
}
答案 0 :(得分:2)
在holder.line_name.setText(line.getName());
之后添加以下行
if (line.getIsFavorite()){
holder.favoriteFilled.setVisibility(View.VISIBLE);
}else{
holder.favoriteFilled.setVisibility(View.GONE);
}