Commit a1afb74e authored by Christophe Deschamps's avatar Christophe Deschamps
Browse files

Highlight selected value in dropdown widgets

No related merge requests found
Pipeline #23012 passed with stage
in 2 minutes and 36 seconds
Showing with 10 additions and 2 deletions
...@@ -72,7 +72,7 @@ class LSpinner : LinearLayout { ...@@ -72,7 +72,7 @@ class LSpinner : LinearLayout {
var items: ArrayList<SpinnerItem>? = null var items: ArrayList<SpinnerItem>? = null
set(value) { set(value) {
binding.root.spinner.adapter = value?.let { LSpinnerAdapter(it, binding.root.spinner, this) } binding.root.spinner.adapter = value?.let { LSpinnerAdapter(it, binding.root.spinner, this, null) }
} }
...@@ -93,6 +93,7 @@ class LSpinner : LinearLayout { ...@@ -93,6 +93,7 @@ class LSpinner : LinearLayout {
set(value) { set(value) {
if (value != null) { if (value != null) {
binding.root.spinner.setSelection(value) binding.root.spinner.setSelection(value)
(binding.root.spinner.adapter as LSpinnerAdapter).selectedIndex = value
} }
} }
......
...@@ -41,7 +41,7 @@ import org.linhome.databinding.ItemSpinnerBinding ...@@ -41,7 +41,7 @@ import org.linhome.databinding.ItemSpinnerBinding
import org.linhome.utils.cdlog import org.linhome.utils.cdlog
class SpinnerItem(val textKey: String, val iconFile: String? = null, val backingKey: String? = null) class SpinnerItem(val textKey: String, val iconFile: String? = null, val backingKey: String? = null)
class LSpinnerAdapter(private val options: ArrayList<SpinnerItem>, val spinner: Spinner, val lSpinner:LSpinner) : class LSpinnerAdapter(private val options: ArrayList<SpinnerItem>, val spinner: Spinner, val lSpinner:LSpinner, var selectedIndex: Int?) :
SpinnerAdapter { SpinnerAdapter {
var height: Int? = null var height: Int? = null
...@@ -114,6 +114,13 @@ class LSpinnerAdapter(private val options: ArrayList<SpinnerItem>, val spinner: ...@@ -114,6 +114,13 @@ class LSpinnerAdapter(private val options: ArrayList<SpinnerItem>, val spinner:
view.visibility = View.VISIBLE view.visibility = View.VISIBLE
} }
if (lSpinner.opened && position == selectedIndex) {
view.background = Theme.roundRectInputBackgroundWithColorKeyAndRadius(
"color_i",
"user_input_corner_radius"
)
}
return view return view
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment