Skip to content

Instantly share code, notes, and snippets.

@douglasiacovelli
Created August 22, 2019 01:41
Show Gist options
  • Select an option

  • Save douglasiacovelli/a5bb0419cba2f349bdcae609789aae8d to your computer and use it in GitHub Desktop.

Select an option

Save douglasiacovelli/a5bb0419cba2f349bdcae609789aae8d to your computer and use it in GitHub Desktop.
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