Here you can find the source of ellipsize(final String text, final int length)
Parameter | Description |
---|---|
text | the text to ellipsize |
length | the max length of the return string |
public static String ellipsize(final String text, final int length)
//package com.java2s; import android.text.TextUtils; public class Main { /**//w ww .j av a 2 s . com * Ellipsizes a text * * @param text * the text to ellipsize * @param length * the max length of the return string * @return an ellipsized string which contains at most lengt characters */ public static String ellipsize(final String text, final int length) { String result; if (TextUtils.isEmpty(text)) { result = ""; } else { result = text; if (result.length() > length) { result = result.substring(0, length - 6) + " [...]"; } } return result; } }