Created
December 12, 2019 23:04
-
-
Save suzp1984/67134895358649695080b89be86563af to your computer and use it in GitHub Desktop.
custom input delegate view
This file contains 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 InputDelegateView @JvmOverloads constructor(context: Context, | |
attrs: AttributeSet? = null, | |
defStyle: Int = 0, | |
defStyleRes: Int = 0): | |
View(context, attrs, defStyle, defStyleRes) { | |
var delegateConnection: InputConnection? = null | |
init { | |
isFocusable = true | |
isFocusableInTouchMode = true | |
} | |
override fun onCreateInputConnection(outAttrs: EditorInfo?): InputConnection { | |
// we should write a custome declare-styleable to custom the inputType, and also the ime options | |
outAttrs?.inputType = InputType.TYPE_CLASS_TEXT | |
return delegateConnection ?: super.onCreateInputConnection(outAttrs) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment