admin管理员组文章数量:1302867
I want to dinamically change inputType in editText, but after first changing suggestions become disabled. I tried different ways to enable, but nothing helps.
This is my code:
edText.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(s: Editable?) {
val curStart = edText.selectionStart
val len = listMarkers.first().length
if (curStart >= len) {
val allText = edText.text.toString()
val marker = allText.slice(curStart - len until curStart)
if (listMarkers.contains(marker)) {
edText.inputType = InputType.TYPE_TEXT_FLAG_CAP_WORDS
}
else {
edText.inputType = InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
}
edText.isSingleLine = false
edText.imeOptions = EditorInfo.IME_ACTION_NONE
edText.setSelection(curStart)
}
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
// TODO Auto-generated method stub
}
override fun beforeTextChanged(
s: CharSequence?,
start: Int,
count: Int,
after: Int
) {
// TODO Auto-generated method stub
}
})
I tried to set different types in block "else". I need to capitalize sentences and enable suggestions.
I even tried to do this:
val type = edText.inputType
edText.inputType = type
But it returns an error.
The same question was already on the site, but I did not find anything useful. How to enable suggestions in an edittext programmatically?
本文标签: javaHow to enable suggestions after change inputType in editTextStack Overflow
版权声明:本文标题:java - How to enable suggestions after change inputType in editText? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741670101a2391550.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论