Android 当我按下它时,有没有办法保持在同一个芯片上?

Android 当我按下它时,有没有办法保持在同一个芯片上?,android,android-chips,Android,Android Chips,你好 我在芯片组中使用芯片,芯片风格主题是选择 如果单击选择芯片,芯片状态将更改。(背景色等) 再次单击它,它将返回到其原始状态 我想要的是,当我点击同一个芯片时,选中的状态不会改变 但我检查另一个芯片处于已检查状态时,前一个芯片的状态必须返回到它的状态 原始状态 是否有支持此功能的属性 换句话说,是否有一个属性可以使选中复选框保持其状态,即使它仍然处于选中状态 被选中 尝试使用java代码,但失败 换句话说,是否有一个属性可以使选中的支票保持其状态,即使它仍然处于状态 被选中 使用芯片选择,然

你好

我在
芯片组中使用
芯片
芯片
风格主题是
选择

如果单击
选择芯片
,芯片状态将更改。(
背景色
等)

再次单击它,它将返回到其原始状态

我想要的是,当我点击同一个芯片时,选中的状态不会改变

但我检查另一个
芯片
处于已检查状态时,前一个芯片的状态必须返回到它的状态

原始状态

是否有支持此功能的属性

换句话说,是否有一个属性可以使
选中复选框保持其状态,即使它仍然处于选中状态

被选中

尝试使用java代码,但失败

换句话说,是否有一个属性可以使选中的支票保持其状态,即使它仍然处于状态

被选中

使用芯片选择,然后将芯片添加到芯片组中

将此线路添加到您的芯片组

<com.google.android.material.chip.ChipGroup
app:singleSelection="true"
app:selectionRequired="true"
app:checkedChip="@id/..."
..>

然后在你的芯片里

<android.support.design.chip.Chip
android:id="@+id/chip1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checkable="true"
android:checked="true"
app:chipBackgroundColor="@color/bg_chip_state_list"
app:chipText="Test1" />

<android.support.design.chip.Chip
android:id="@+id/chip2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checkable="true"
app:chipBackgroundColor="@color/bg_chip_state_list"
app:chipText="Test2" />


关键是需要选择的芯片组。。非常感谢。但是在你的链接上,
style
不起作用。
@color
不起作用。
运行Android Studio时,右键点击你项目的
Res
目录,然后点击
New->New resource file
并选择
resource type
作为颜色,然后创建你的
bg\u芯片状态列表
color file.OMG,我解决了!非常感谢。