How do I store a layout created via ViewManager
in a variable and pass it to another function without it rendering whilst being stored in the said variable
Example Code
1) The spinner Layout
fun ViewManager.spinnerLayout(
spinner: Spinner
) = linearLayout {
lparams(width = matchParent) { weightSum = 2.toFloat() }
textView {
textSize = 18f
textColor = colorWhite
text = "tested"
}.lparams{ weight = 1.toFloat() }
spinner.lparams{ weight = 1.toFloat() } // The spinner is rendered here
}
2) The spinner itself
fun ViewManager.spinner() = spinner {
id = R.id.mySpin
prompt = "Select A Option"
}
The problem is that if I use the below code to call the spinner()
and pass that variable to the spinnerLayout()
function, the spinner is echoed twice. So, I want to know how do I store it in the variable without it rendering
mySpinner = spinner() // It renders here
spinnerLayout(mySpinner) // and here