Commit 81845301598ac0b3d3a960686d9928006cbc4905
1 parent
b4bc21d212
Exists in
master
选中题目时展示边框
Showing
2 changed files
with
24 additions
and
0 deletions
Show diff stats
app/src/main/java/com/hjx/parent/HomeworkSelectActivity.java
| ... | ... | @@ -3,14 +3,17 @@ package com.hjx.parent; |
| 3 | 3 | import android.annotation.SuppressLint; |
| 4 | 4 | import android.content.Intent; |
| 5 | 5 | import android.content.res.ColorStateList; |
| 6 | +import android.graphics.drawable.Drawable; | |
| 6 | 7 | import android.os.Bundle; |
| 7 | 8 | import android.view.View; |
| 8 | 9 | import android.widget.CheckBox; |
| 9 | 10 | import android.widget.ImageView; |
| 10 | 11 | import android.widget.TextView; |
| 11 | 12 | |
| 13 | +import androidx.annotation.DrawableRes; | |
| 12 | 14 | import androidx.annotation.NonNull; |
| 13 | 15 | import androidx.annotation.Nullable; |
| 16 | +import androidx.core.content.res.ResourcesCompat; | |
| 14 | 17 | import androidx.lifecycle.MutableLiveData; |
| 15 | 18 | |
| 16 | 19 | import com.bumptech.glide.Glide; |
| ... | ... | @@ -108,6 +111,11 @@ public class HomeworkSelectActivity extends BaseRxActivity<ActivityHomeworkSelec |
| 108 | 111 | tvNumber.setText("第" + number + "题"); |
| 109 | 112 | Glide.with(mContext).load(homeWork.url).into(imageView); |
| 110 | 113 | |
| 114 | + if (homeWork.check) { | |
| 115 | + holder.itemView.setForeground(getDrawable(R.drawable.border_radius_10_red)); | |
| 116 | + } else { | |
| 117 | + holder.itemView.setForeground(null); | |
| 118 | + } | |
| 111 | 119 | CheckBox checkBox = holder.getView(R.id.checkbox); |
| 112 | 120 | checkBox.setVisibility(View.VISIBLE); |
| 113 | 121 | checkBox.setOnCheckedChangeListener(null); |
| ... | ... | @@ -119,7 +127,16 @@ public class HomeworkSelectActivity extends BaseRxActivity<ActivityHomeworkSelec |
| 119 | 127 | if (selectCall != null) { |
| 120 | 128 | selectCall.invoke(b ? 1 : -1); |
| 121 | 129 | } |
| 130 | + if (homeWork.check) { | |
| 131 | + holder.itemView.setForeground(getDrawable(R.drawable.border_radius_10_red)); | |
| 132 | + } else { | |
| 133 | + holder.itemView.setForeground(null); | |
| 134 | + } | |
| 122 | 135 | }); |
| 123 | 136 | } |
| 137 | + | |
| 138 | + private Drawable getDrawable(@DrawableRes int res) { | |
| 139 | + return ResourcesCompat.getDrawable(mContext.getResources(), res, null); | |
| 140 | + } | |
| 124 | 141 | } |
| 125 | 142 | } | ... | ... |
app/src/main/res/drawable/border_radius_10_red.xml