Adding a default popup for selectedPosition in spinner view

For cases where neither bind no listener is implmented, you can just get the selected position
This commit is contained in:
Jays2Kings 2021-04-14 15:50:09 -04:00
parent f0fbab56af
commit d584aa56b9

View File

@ -25,7 +25,8 @@ class MaterialSpinnerView @JvmOverloads constructor(context: Context, attrs: Att
FrameLayout(context, attrs) { FrameLayout(context, attrs) {
private var entries = emptyList<String>() private var entries = emptyList<String>()
private var selectedPosition = 0 var selectedPosition = 0
private set
private var pref: Preference<Int>? = null private var pref: Preference<Int>? = null
private var prefOffset = 0 private var prefOffset = 0
private var popup: PopupMenu? = null private var popup: PopupMenu? = null
@ -63,6 +64,12 @@ class MaterialSpinnerView @JvmOverloads constructor(context: Context, attrs: Att
binding.detailView.text = entries.firstOrNull().orEmpty() binding.detailView.text = entries.firstOrNull().orEmpty()
popup = makeSettingsPopup()
setOnTouchListener(popup?.dragToOpenListener)
setOnClickListener {
popup?.show()
}
a.recycle() a.recycle()
} }