If you are not interested in xml solutions, you can do this:
String s="Hello world"; Textview someTextView; someTextView.setText(getSafeSubstring(s, 5));
...
public String getSafeSubstring(String s, int maxLength){ if(!TextUtils.isEmpty(s)){ if(s.length() >= maxLength){ return s.substring(0, maxLength); } } return s; }
Darko Petkovski Sep 27 '14 at 7:56 on 2014-09-27 07:56
source share