diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDropdownMenu.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDropdownMenu.kt index c2e7e21544..3bf7110d6d 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDropdownMenu.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDropdownMenu.kt @@ -26,8 +26,10 @@ class InputDropdownMenu(private val resourceHelper: ResourceHelper) : Element() override fun addToLayout(root: LinearLayout) { val spinner = Spinner(root.context) - spinner.adapter = ArrayAdapter(root.context, - R.layout.spinner_centered, itemList).also { + spinner.adapter = ArrayAdapter( + root.context, + R.layout.spinner_centered, itemList + ).also { it.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) } spinner.layoutParams = LinearLayout.LayoutParams( @@ -42,7 +44,7 @@ class InputDropdownMenu(private val resourceHelper: ResourceHelper) : Element() override fun onNothingSelected(parent: AdapterView<*>?) {} } - spinner.setSelection(0) + for (i in 0 until itemList.size) if (itemList[i] == value) spinner.setSelection(i) root.addView(LinearLayout(root.context).also { it.orientation = LinearLayout.VERTICAL it.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT) diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputProfileName.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputProfileName.kt index 967f22e0bf..a6f464bafe 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputProfileName.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputProfileName.kt @@ -34,7 +34,7 @@ class InputProfileName(private val resourceHelper: ResourceHelper, private val a override fun onNothingSelected(parent: AdapterView<*>?) {} } - spinner.setSelection(0) + for (i in 0 until profileList.size) if (profileList[i] == value) spinner.setSelection(i) val l = LinearLayout(root.context) l.orientation = LinearLayout.VERTICAL l.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)