Android examples for java.lang:Character
Ellipsize string with maxCharacter
import android.text.TextUtils; import android.widget.TextView; import java.util.Calendar; public class Main{ public static String ellipsize(String input, int maxCharacters) { if (maxCharacters < 3) { throw new IllegalArgumentException( "maxCharacters must be at least 3 because the ellipsis already take up 3 characters"); }/*from www .jav a 2 s . c o m*/ if (input == null || input.length() < maxCharacters) { return input; } return input.substring(0, maxCharacters - 3) + "..."; } }