I have a problem. I am creating an AnkoView in a F...
# anko
j
I have a problem. I am creating an AnkoView in a Fragment, and I want to get a result from a (Realm) database to be displayed in a Spinner. So I am using doAsync{ //Get the Result } But now I am stuck as I don't actually know how to assign it to the spinner. I have no idea how do I access my view variables. This is what I have in onCreateView
Copy code
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View {
        val editTextTheme = R.style.Widget_AppCompat_EditText

        val ui = UI {
            verticalLayout {
                verticalPadding =dip(15)
                gravity = Gravity.CENTER
                var description = editText(editTextTheme){
                    id = R.id.txt_todo_desc
                    hintResource = R.string.txt_todo_desc_hint
                    width = matchParent

                }
                var category = spinner(R.style.Base_Widget_AppCompat_Spinner){
                    id= R.id.spinner_todo_category
                }
                button{
                    id = R.id.btn_add_todo
                    textResource = R.string.btn_add_todo
                    width = matchParent
                    onClick { view -> createTodoFrom(description, category) }
                }

            }.applyRecursively {view -> when(view){
                is EditText -> view.textSize = 20f
                is Button -> view.textSize = 30f
            }

            }
        }
        doAsync {
            val result = realm.where(Category::class.java).findAll()

            uiThread {
                updateCategorySpinner(result)
            }
        }

        return ui.view
    }
`