Anko: android.support.design.widget.TextInputEditText

Created on 10 Jun 2016  路  6Comments  路  Source: Kotlin/anko

Hello!

Please, add this widget to your DSL.

Thanks!

Anko Layouts feature

Most helpful comment

Define this somewhere:

inline fun ViewManager.textInputEditText() = textInputEditText {}
inline fun ViewManager.textInputEditText(theme: Int = 0, init: TextInputEditText.() -> Unit) = ankoView({ TextInputEditText(it) }, theme, init)

and you'll be able to write this:

textInputLayout {
    textInputEditText {
        ...
    }
 }

All 6 comments

Now, with the new com.android.support:design:24.2.0 library, apps force close: java.lang.ClassCastException: android.widget.EditText cannot be cast to android.support.design.widget.TextInputEditText

Any workaround to use before TextInputEditText is added in anko @yanex ?

Define this somewhere:

inline fun ViewManager.textInputEditText() = textInputEditText {}
inline fun ViewManager.textInputEditText(theme: Int = 0, init: TextInputEditText.() -> Unit) = ankoView({ TextInputEditText(it) }, theme, init)

and you'll be able to write this:

textInputLayout {
    textInputEditText {
        ...
    }
 }

@abond working perfectly, thanks for the help!

@abond Could you please elaborate ? Why does this work ?

@Rahulkr2 The principles of building DSL's in Kotlin well described in this article https://kotlinlang.org/docs/reference/type-safe-builders.html.
Reading it should help you understand how Anko DSL works.

how to make XML android.support.design.widget.TextInputEditText in kotlin?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maomaobug picture maomaobug  路  4Comments

jonathanlip1100 picture jonathanlip1100  路  4Comments

vlonjatg picture vlonjatg  路  3Comments

bapspatil picture bapspatil  路  4Comments

jeantuffier picture jeantuffier  路  5Comments