CheckBox
Android
Component in Jetpack Glance
Adds a check box view to the glance view.
Last updated:
Installation
dependencies {
implementation("androidx.glance:glance-appwidget:1.1.1")
}
Overloads
@Composable
fun CheckBox(
checked: Boolean,
onCheckedChange: Action?,
modifier: GlanceModifier = GlanceModifier,
text: String = "",
style: TextStyle? = null,
colors: CheckBoxColors = CheckboxDefaults.colors(),
maxLines: Int = Int.MAX_VALUE,
)
Parameters
name | description |
---|---|
checked | whether the check box is checked |
onCheckedChange | the action to be run when the checkbox is clicked. The current value ofchecked is provided to this action in its ActionParameters, and can be retrieved using the[ToggleableStateKey]. If this action launches an activity, the current value of checked will bepassed as an intent extra with the name [RemoteViews.EXTRA_CHECKED].In order to allow the Launcher to provide this extra on Android version S and later, we use amutable PendingIntent ([android.app.PendingIntent.FLAG_MUTABLE]) when this action is not alambda. Before S, and for lambda actions, this will be an immutable PendingIntent. |
modifier | the modifier to apply to the check box |
text | the text to display to the end of the check box |
style | the style to apply to [text] |
colors | the color tint to apply to the check box |
maxLines | An optional maximum number of lines for the text to span, wrapping ifnecessary. If the text exceeds the given number of lines, it will be truncated. |
@Composable
fun CheckBox(
checked: Boolean,
onCheckedChange: () -> Unit,
modifier: GlanceModifier = GlanceModifier,
text: String = "",
style: TextStyle? = null,
colors: CheckBoxColors = CheckboxDefaults.colors(),
maxLines: Int = Int.MAX_VALUE,
)
Parameters
name | description |
---|---|
checked | whether the check box is checked |
onCheckedChange | the action to be run when the checkbox is clicked |
modifier | the modifier to apply to the check box |
text | the text to display to the end of the check box |
style | the style to apply to [text] |
colors | the color tint to apply to the check box |
maxLines | An optional maximum number of lines for the text to span, wrapping ifnecessary. If the text exceeds the given number of lines, it will be truncated. |
@ExperimentalGlanceApi
@Composable
fun CheckBox(
checked: Boolean,
onCheckedChange: () -> Unit,
modifier: GlanceModifier = GlanceModifier,
text: String = "",
style: TextStyle? = null,
colors: CheckBoxColors = CheckboxDefaults.colors(),
maxLines: Int = Int.MAX_VALUE,
key: String? = null,
)
Parameters
name | description |
---|---|
checked | whether the check box is checked |
onCheckedChange | the action to be run when the checkbox is clicked |
modifier | the modifier to apply to the check box |
text | the text to display to the end of the check box |
style | the style to apply to [text] |
colors | the color tint to apply to the check box |
maxLines | An optional maximum number of lines for the text to span, wrapping ifnecessary. If the text exceeds the given number of lines, it will be truncated. |
key | A stable and unique key that identifies the action for this checkbox. This ensuresthat the correct action is triggered, especially in cases of items that change order. If notprovided we use the key that is automatically generated by the Compose runtime, which is uniquefor every exact code location in the composition tree. |