本文整理汇总了Java中android.text.TextUtils.substring方法的典型用法代码示例。如果您正苦于以下问题:Java TextUtils.substring方法的具体用法?Java TextUtils.substring怎么用?Java TextUtils.substring使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.text.TextUtils
的用法示例。
在下文中一共展示了TextUtils.substring方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRecipientAt
import android.text.TextUtils; //导入方法依赖的package包/类
private static Recipient getRecipientAt(Spanned sp, int start, int end) {
Annotation[] a = sp.getSpans(start, end, Annotation.class);
String person_id = getAnnotation(a, "person_id");
String name = getAnnotation(a, "name");
String label = getAnnotation(a, "label");
String bcc = getAnnotation(a, "bcc");
String number = getAnnotation(a, "number");
Recipient r = new Recipient();
r.name = name;
r.label = label;
r.bcc = bcc.equals("true");
r.number = TextUtils.isEmpty(number) ? TextUtils.substring(sp, start, end) : number;
r.nameAndNumber = Recipient.buildNameAndNumber(r.name, r.number);
if (person_id.length() > 0) {
r.person_id = Long.parseLong(person_id);
} else {
r.person_id = -1;
}
return r;
}
示例2: getFieldAt
import android.text.TextUtils; //导入方法依赖的package包/类
private static String getFieldAt(String field, Spanned sp, int start, int end,
Context context) {
Annotation[] a = sp.getSpans(start, end, Annotation.class);
String fieldValue = getAnnotation(a, field);
if (TextUtils.isEmpty(fieldValue)) {
fieldValue = TextUtils.substring(sp, start, end);
}
return fieldValue;
}
示例3: getNonAutocompleteText
import android.text.TextUtils; //导入方法依赖的package包/类
/**
* Get the portion of text that is not marked as autocomplete text.
*
* @param text Current text content that may include autocomplete text
*/
private static String getNonAutocompleteText(final Editable text) {
final int start = text.getSpanStart(AUTOCOMPLETE_SPAN);
if (start < 0) {
// No autocomplete text; return the whole string.
return text.toString();
}
// Only return the portion that's not autocomplete text
return TextUtils.substring(text, 0, start);
}