安卓工作室 3.6
在 xml 布局中,我有这个:
<com.google.android.material.card.MaterialCardView
android:id="@+id/cardPaymentCardView"
style="@style/cardViewStyle"
android:layout_width="0dp"
android:layout_height="0dp"
app:checkedIcon="@drawable/ic_credit_card_outline_select"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
要打开/关闭检查状态,我使用它(在我的活动中)
dataBinding.cardPaymentCardView.isChecked = !dataBinding.cardPaymentCardView.isChecked
它工作正常。好的。
但是我需要直接在xml中设置检查状态。像这样:
android:checked_state="true"
但我得到编译错误