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

Highlight selected value in dropdown widgets

parent 7edd6b81
......@@ -72,7 +72,7 @@ class LSpinner : LinearLayout {
var items: ArrayList<SpinnerItem>? = null
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 {
set(value) {
if (value != null) {
binding.root.spinner.setSelection(value)
(binding.root.spinner.adapter as LSpinnerAdapter).selectedIndex = value
}
}
......
......@@ -41,7 +41,7 @@ import org.linhome.databinding.ItemSpinnerBinding
import org.linhome.utils.cdlog
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 {
var height: Int? = null
......@@ -114,6 +114,13 @@ class LSpinnerAdapter(private val options: ArrayList<SpinnerItem>, val spinner:
view.visibility = View.VISIBLE
}
if (lSpinner.opened && position == selectedIndex) {
view.background = Theme.roundRectInputBackgroundWithColorKeyAndRadius(
"color_i",
"user_input_corner_radius"
)
}
return view
}
......
Markdown is supported
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