Search code examples
androidstringtextview

How to set specific characters of a string to a text view instead of whole string?


I've a string with complete language name and I wanted to set first two characters of that language name to my text view. Like I've a language name AFRIKAANS and I only wanted to set AF on my text view. How can I do this


Solution

  • String string = "AFRIKAANS";
    yourTextView.setText(string.substring(0, 2));