First of all, thanks for creating this excellent tool.
I'm trying to get it to work in an alert dialog (basically as a mini-form that you fill out and click "ok"). To do this, I create the MultiSpinnerSearch programatically, as below, but it does not display. (It does display correctly when create within the Activity's XML file).
val allSources = listOf("manual", "auto")
val spinner = MultiSpinnerSearch(applicationContext).apply{
title="Source"
setItems(allSources.map{ KeyPairBoolData(it, false) }){}
}
val exampleText = Button(applicationContext).apply{text="Example"; setOnClickListener{showToast("Button Pressed")}}
val form = LinearLayout(applicationContext, ).apply{
orientation=LinearLayout.VERTICAL;
addView(spinner);
addView(exampleText)
}
AlertDialog.Builder(this)
.setView(form)
.setPositiveButton("Filter") { _, _ ->
updateDetectionDisplayAsync()
showToast("Updated detections")
}
.setNegativeButton("Cancel") { _, _ -> }
.create().show()
I believe it's to do with the fact that building programatically uses the MultiSpinnerSearch(context) constructor instead of the MultiSpinnerSearch(context, attributes) constructor used when building from xml. I tried constructing fake attributes to construct the other way but ran into a dead end there where constructing a valid fake attributes object seemed complicated.
I'm not sure whether the solution to this involves modifying the source code of MultiSelectSpinner - any pointers appreciated and if it's not too involved I could possibly figure it out and make a PR with the fix.
First of all, thanks for creating this excellent tool.
I'm trying to get it to work in an alert dialog (basically as a mini-form that you fill out and click "ok"). To do this, I create the
MultiSpinnerSearch
programatically, as below, but it does not display. (It does display correctly when create within the Activity's XML file).I believe it's to do with the fact that building programatically uses the
MultiSpinnerSearch(context)
constructor instead of theMultiSpinnerSearch(context, attributes)
constructor used when building from xml. I tried constructing fake attributes to construct the other way but ran into a dead end there where constructing a valid fake attributes object seemed complicated.I'm not sure whether the solution to this involves modifying the source code of
MultiSelectSpinner
- any pointers appreciated and if it's not too involved I could possibly figure it out and make a PR with the fix.