Linjiajia
2023-12-29 590c1cff46b105d774271f950caa9f65523f05c1
app/src/main/java/com/application/zhangshi_app_android/adapter/PetRvAdapter.java
@@ -2,6 +2,7 @@
import android.content.Context;
import android.content.Intent;
import android.util.TypedValue;
import android.view.View;
import com.android.app_base.base.adapter.BaseRVAdapter;
@@ -33,10 +34,15 @@
    @Override
    protected void onBind(BaseViewHolder<ItemPetBinding> holder, int position) {
        holder.getBinding().setBean(mDataList.get(position));
        //根据主题选择对应卡片背景色
        TypedValue typedValue1 = new TypedValue();
        mContext.getTheme().resolveAttribute(R.attr.cardBackgroundColorFirst, typedValue1, true);
        TypedValue typedValue2 = new TypedValue();
        mContext.getTheme().resolveAttribute(R.attr.cardBackgroundColorSecond, typedValue2, true);
        if (position % 2 != 0){
            holder.getBinding().cardView.setCardBackgroundColor(mContext.getColor(R.color.color_card_blue));
            holder.getBinding().cardView.setCardBackgroundColor(typedValue1.data);
        }else {
            holder.getBinding().cardView.setCardBackgroundColor(mContext.getColor(R.color.color_card_pink));
            holder.getBinding().cardView.setCardBackgroundColor(typedValue2.data);
        }
        if (mDataList.get(position).getOwnData() == 1){
            holder.getBinding().ivFlower.setVisibility(View.VISIBLE);