![]() |
![]() |
![]() |
|---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
dependencies {
implementation 'net.mm2d.color-chooser:color-chooser-compose:<version>'
}var show by rememberSaveable { mutableStateOf(false) }
...
if (!show) return
ColorChooserDialog(
initialColor = Color(color),
onDismissRequest = {
show = false
// dismiss the dialog
},
onChooseColor = { color ->
// handle chosen color
},
)dependencies {
implementation 'net.mm2d.color-chooser:color-chooser:<version>'
}Register the listener to receive the result. Write the following process in onViewCreated of Fragment or onCreate of Activity.
ColorChooserDialog.registerListener(REQUEST_KEY, this) {
// it is selected color as @ColorInt
}To show dialog. On FragmentActivity or Fragment
ColorChooserDialog.show(
this, // Fragment or FragmentActivity
REQUEST_KEY, // request key for receive result
initialColor, // initial color, optional, default #FFFFFF
true, // need for alpha, optional, default false
TAB_RGB // initial tab, TAB_PALETTE/TAB_HSV/TAB_RGB, optional, default TAB_PALETTE
)The style of implementing a callback interface in Activity and Fragment has been deprecated.
Please see Sample code for detail.
大前 良介 (OHMAE Ryosuke) http://www.mm2d.net/








