当前位置: 首页>>代码示例>>Java>>正文


Java TextUtils.concat方法代码示例

本文整理汇总了Java中android.text.TextUtils.concat方法的典型用法代码示例。如果您正苦于以下问题:Java TextUtils.concat方法的具体用法?Java TextUtils.concat怎么用?Java TextUtils.concat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.text.TextUtils的用法示例。


在下文中一共展示了TextUtils.concat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getViewAt

import android.text.TextUtils; //导入方法依赖的package包/类
@Override
public RemoteViews getViewAt(int position) {
    ScheduleDailyGroupModel model = list.get(position);
    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.layout_schedule_daily_widget);

    remoteViews.setTextViewText(R.id.title_schedule_daily, model.day);

    CharSequence builder = null;
    for (ScheduleDailyModel e : model.scheduleDailyModels()) {
        String course = e.desc.substring(0, e.desc.indexOf(" Ruang: "));
        String room = e.desc.substring(e.desc.indexOf(" Ruang: ") + 8);
        SpannableString title = new SpannableString(course);
        title.setSpan(new RelativeSizeSpan(1.2f), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        SpannableString time = new SpannableString("R. " + room + "\t\t" + e.time);
        time.setSpan(new ForegroundColorSpan(context.getResources().getColor(android.R.color.darker_gray)), 0, time.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        if (builder == null) {
            builder = TextUtils.concat(title, "\n", time + "\n\n");
        } else {
            builder = TextUtils.concat(builder, title, "\n", time + "\n\n");
        }
    }
    remoteViews.setTextViewText(R.id.content_schedule_daily, builder == null ? "(empty)\n\n" : builder);

    return remoteViews;
}
 
开发者ID:mgilangjanuar,项目名称:GoSCELE,代码行数:26,代码来源:ScheduleDailyProvider.java

示例2: markdownToSpannable

import android.text.TextUtils; //导入方法依赖的package包/类
public CharSequence markdownToSpannable(String markdown, ImageGetter imageGetter) {
    Document document = processMarkdown(markdown);

    int size = document.getElementCount();
    CharSequence[] spans = new CharSequence[size];

    for (int i = 0; i < size; i++) {
        spans[i] = recurseElement(document.getElement(i), i, size, imageGetter);
    }

    return TextUtils.concat(spans);
}
 
开发者ID:PaulKlinger,项目名称:Sprog-App,代码行数:13,代码来源:Bypass.java

示例3: filter

import android.text.TextUtils; //导入方法依赖的package包/类
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
    CharSequence returnStr = source;
    String curStr = dest.subSequence(dstart, dend).toString();
    String newStr = source.toString();
    int length = end - start;
    int dlength = dend - dstart;
    if (dlength > 0 && length == 0) {
        // Case: Remove chars, Simple
        returnStr = TextListener.this.removeStr(dest.subSequence(dstart, dend), dstart);
    } else if (length > 0 && dlength == 0) {
        // Case: Insert chars, Simple
        returnStr = TextListener.this.insertStr(source.subSequence(start, end), dstart);
    } else if (curStr.length() > newStr.length()) {
        // Case: Remove string or replace
        if (curStr.startsWith(newStr)) {
            // Case: Insert chars, by append
            returnStr = TextUtils.concat(curStr.subSequence(0, newStr.length()), TextListener.this.removeStr(curStr.subSequence(newStr.length(), curStr.length()), dstart + curStr.length()));
        } else {
            // Case Replace chars.
            returnStr = TextListener.this.updateStr(curStr, dstart, newStr);
        }
    } else if (curStr.length() < newStr.length()) {
        // Case: Append String or rrepace.
        if (newStr.startsWith(curStr)) {
            // Addend, Insert
            returnStr = TextUtils.concat(curStr, TextListener.this.insertStr(newStr.subSequence(curStr.length(), newStr.length()), dstart + curStr.length()));
        } else {
            returnStr = TextListener.this.updateStr(curStr, dstart, newStr);
        }
    } else {
        // No update os str...
    }

    // If the return value is same as the source values, return the source value.
    return returnStr;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:37,代码来源:ConsoleEditText.java

示例4: setAutocompleteText

import android.text.TextUtils; //导入方法依赖的package包/类
/**
 * Autocompletes the text on the url bar and selects the text that was not entered by the
 * user. Using append() instead of setText() to preserve the soft-keyboard layout.
 * @param userText user The text entered by the user.
 * @param inlineAutocompleteText The suggested autocompletion for the user's text.
 */
public void setAutocompleteText(CharSequence userText, CharSequence inlineAutocompleteText) {
    boolean emptyAutocomplete = TextUtils.isEmpty(inlineAutocompleteText);

    if (!emptyAutocomplete) mDisableTextScrollingFromAutocomplete = true;

    int autocompleteIndex = userText.length();

    String previousText = getQueryText();
    CharSequence newText = TextUtils.concat(userText, inlineAutocompleteText);

    setIgnoreTextChangesForAutocomplete(true);
    mDisableTextAccessibilityEvents = true;

    if (!TextUtils.equals(previousText, newText)) {
        // The previous text may also have included autocomplete text, so we only
        // append the new autocomplete text that has changed.
        if (TextUtils.indexOf(newText, previousText) == 0) {
            append(newText.subSequence(previousText.length(), newText.length()));
        } else {
            setUrl(newText.toString(), null);
        }
    }

    if (getSelectionStart() != autocompleteIndex
            || getSelectionEnd() != getText().length()) {
        setSelection(autocompleteIndex, getText().length());

        if (inlineAutocompleteText.length() != 0) {
            // Sending a TYPE_VIEW_TEXT_SELECTION_CHANGED accessibility event causes the
            // previous TYPE_VIEW_TEXT_CHANGED event to be swallowed. As a result the user
            // hears the autocomplete text but *not* the text they typed. Instead we send a
            // TYPE_ANNOUNCEMENT event, which doesn't swallow the text-changed event.
            announceForAccessibility(inlineAutocompleteText);
        }
    }

    if (emptyAutocomplete) {
        mAutocompleteSpan.clearSpan();
    } else {
        mAutocompleteSpan.setSpan(userText, inlineAutocompleteText);
    }

    setIgnoreTextChangesForAutocomplete(false);
    mDisableTextAccessibilityEvents = false;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:52,代码来源:UrlBar.java


注:本文中的android.text.TextUtils.concat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。