Created
August 22, 2019 01:41
-
-
Save douglasiacovelli/a5bb0419cba2f349bdcae609789aae8d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class TextInput @JvmOverloads constructor(context: Context, attrSet: AttributeSet? = null, defStyleAttr: Int = 0) | |
| : FrameLayout(context, attrSet, defStyleAttr), FieldInput { | |
| override var key: String = "" | |
| private val textInput: TextInputEditText | |
| init { | |
| val view = inflate(context, R.layout.text_input, this) | |
| textInput = view.findViewById(R.id.editText) | |
| //This is necessary to avoid having the same component twice on the screen with the same id. | |
| textInput.id = View.generateViewId() | |
| } | |
| override fun getValue(): String { | |
| return textInput.text.toString() | |
| } | |
| override fun setHint(hint: String) { | |
| textInput.hint = hint | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment