I'm using EditText for search functionality. But I when type something focus on Edittext. the keyboard appears but not typing until I click again on EditText. Note: if I comment submit code then focus works fine. here is my code.
fun filterList(text: String) {
val filterdNames = ArrayList<IRTv_model_class>()
//looping through existing elements
for (s in mProductArrayList) {
//if the existing elements contains the search input
if (s.name.lowercase(Locale.getDefault())
.contains(text.lowercase(Locale.getDefault()))
) {
//adding the element to filtered list
filterdNames.add(s)
}
}
mAdapter?.submitList(filterdNames)
}
the filterList() method I called on afterTextChanged method using TextWatcher.
binding.etSearch.addTextChangedListener(object : TextWatcher {
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
}
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
override fun afterTextChanged(s: Editable) {
filterList(s.toString())
}
})