I\'m trying to write new custom style for my android application. I need to give style to errorText which appears after setting setError
in EditText
This works fine!
private fun setErrorOnSearchView(searchView: SearchView, errorMessage:
String) {
val id = searchView.context
.resources
.getIdentifier("android:id/search_src_text", null, null)
val editText = searchView.find(id)
val errorColor = ContextCompat.getColor(this,R.color.red)
val fgcspan = ForegroundColorSpan(errorColor)
val builder = SpannableStringBuilder(errorMessage)
builder.setSpan(fgcspan, 0, errorMessage.length, 0)
editText.error = builder
}