Issue
val textoData = itemView.findViewById(R.id.texto_data_abastecimento) textoData.text = abastecimento.datam.toString().subSequence(0..10)
val textoHora = itemView.findViewById<TextView>(R.id.texto_hora_abastecimento)
textoHora.text = abastecimento.hodomDm.toString().subSequence(0..5)
I'm trying to use only the first 5 characters for display on the adapter and I end up getting the following error:
java.lang.StringIndexOutOfBoundsException: length=0; index=6
Solution
You can easily use the substring(0,5)
extension function of Kotlin standard library.
textoHora.text = abastecimento.hodomDm.toString().substring(0,5)
Answered By - Alireza Nezami
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.