Can you help me with my code? I am changing the color of the item based on the information from the database, and now I wanted to transfer the color to the CardView, but I don't know what the notation should look like, because this code tells me that the Color.RED write is wrong. Will you help me?
@Override
protected void onBindViewHolder(@NonNull holder holder, int position, @NonNull
VoiceModel model) {
holder.tvvoiceName.setText(model.getName());
holder.tvvoiceTime.setText(model.getTime());
if(model.getPremium() == 1) holder.voice_item.getCardBackgroundColor(Color.RED);
You have to use setCardBackgroundColor
not getCardBackgroundColor
. Then your code should be:
holder.voice_item.setCardBackgroundColor(Color.RED);