當前位置: 首頁>>代碼示例>>Java>>正文


Java Editable.removeSpan方法代碼示例

本文整理匯總了Java中android.text.Editable.removeSpan方法的典型用法代碼示例。如果您正苦於以下問題:Java Editable.removeSpan方法的具體用法?Java Editable.removeSpan怎麽用?Java Editable.removeSpan使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.text.Editable的用法示例。


在下文中一共展示了Editable.removeSpan方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleIgnoredTag

import android.text.Editable; //導入方法依賴的package包/類
/**
 * When we come upon an ignored tag, we mark it with an Annotation object with a specific key
 * and value as above. We don't really need to be checking these values since Html.fromHtml()
 * doesn't use Annotation spans, but we should do it now to be safe in case they do start using
 * it in the future.
 * @param opening If this is an opening tag or not.
 * @param output Spannable string that we're working with.
 */
private void handleIgnoredTag(boolean opening, Editable output) {
    int len = output.length();
    if (opening) {
        output.setSpan(new Annotation(IGNORED_ANNOTATION_KEY, IGNORED_ANNOTATION_VALUE), len,
                       len, Spannable.SPAN_MARK_MARK);
    } else {
        Object start = getOpeningAnnotation(output);
        if (start != null) {
            int where = output.getSpanStart(start);
            // Remove the temporary Annotation span.
            output.removeSpan(start);
            // Delete everything between the start of the Annotation and the end of the string
            // (what we've generated so far).
            output.delete(where, len);
        }
    }
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:26,代碼來源:HtmlConverter.java

示例2: setTextSize

import android.text.Editable; //導入方法依賴的package包/類
/**
 * 設置字體大小
 * @param textSize textSize
 */
void setTextSize(int textSize) {
    Editable edit = getEditableText();
    int index = getSelectionIndex();
    int star = getSectionStart();
    int end = getSectionEnd();
    if (star >= end)
        return;
    if (index >= 0 && index < mSections.size()) {
        TextSection section = mSections.get(index);
        section.setTextSize(textSize);
        if (mListener != null) {
            mListener.onSectionChange(section);
        }
    }
    AbsoluteSizeSpan[] styleSpans = edit.getSpans(star, end, AbsoluteSizeSpan.class);
    for (AbsoluteSizeSpan span : styleSpans) {
        edit.removeSpan(span);
    }
    edit.setSpan(new AbsoluteSizeSpan(UI.dipToPx(getContext(), textSize)), star, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    update(index);
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:26,代碼來源:RichEditText.java

示例3: undo

import android.text.Editable; //導入方法依賴的package包/類
public void undo() {
    EditItem edit = mEditHistory.getPrevious();
    if (edit == null) {
        return;
    }

    Editable editable = mTextView.getEditableText();
    int start = edit.start;
    int end = start + (edit.after != null ? edit.after.length() : 0);

    mIsUndoOrRedo = true;
    editable.replace(start, end, edit.before);
    mIsUndoOrRedo = false;

    for (Object o : editable.getSpans(0, editable.length(), UnderlineSpan.class)) {
        editable.removeSpan(o);
    }

    Selection.setSelection(editable, edit.before == null ? start : (start + edit.before.length()));
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:21,代碼來源:UndoRedoSupportEditText.java

示例4: redo

import android.text.Editable; //導入方法依賴的package包/類
public void redo() {
    EditItem edit = mEditHistory.getNext();
    if (edit == null) {
        return;
    }

    Editable text = mTextView.getEditableText();
    int start = edit.start;
    int end = start + (edit.before != null ? edit.before.length() : 0);

    mIsUndoOrRedo = true;
    text.replace(start, end, edit.after);
    mIsUndoOrRedo = false;

    // This will get rid of underlines inserted when editor tries to come
    // up with a suggestion.
    for (Object o : text.getSpans(0, text.length(), UnderlineSpan.class)) {
        text.removeSpan(o);
    }

    Selection.setSelection(text, edit.after == null ? start
            : (start + edit.after.length()));
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:24,代碼來源:UndoRedoSupportEditText.java

示例5: undo

import android.text.Editable; //導入方法依賴的package包/類
public void undo() {
    EditItem edit = mEditHistory.getPrevious();
    if (edit == null) {
        return;
    }

    Editable editable = mTextView.getEditableText();
    int start = edit.start;
    int end = start + (edit.after != null ? edit.after.length() : 0);

    mIsUndoOrRedo = true;
    editable.replace(start, end, edit.before);
    mIsUndoOrRedo = false;

    for (Object o : editable.getSpans(0, editable.length(), UnderlineSpan.class)) {
        editable.removeSpan(o);
    }

    Selection.setSelection(editable,
            edit.before == null ? start : (start + edit.before.length()));
}
 
開發者ID:Light-Team,項目名稱:ModPE-IDE-Source,代碼行數:22,代碼來源:UndoRedoHelper.java

示例6: afterTextChanged

import android.text.Editable; //導入方法依賴的package包/類
@Override
public void afterTextChanged(Editable s) {
    final RichEditText.TagSpan span = willDelSpan;
    log("TagSpanTextWatcher#willRemove#span:" + (span == null ? "null" : span.toString()));
    if (span != null && span.willRemove) {
        int start = s.getSpanStart(span);
        int end = s.getSpanEnd(span);

        // Remove the span
        s.removeSpan(span);

        // Remove the remaining emoticon text.
        if (start != end) {
            s.delete(start, end);
        }
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:18,代碼來源:RichEditText.java

示例7: setBold

import android.text.Editable; //導入方法依賴的package包/類
void setBold(boolean isBold) {
    int index = getSelectionIndex();
    if (index >= 0 && index < mSections.size()) {
        mSections.get(index).setBold(isBold);
    }
    Editable edit = getEditableText();
    int star = getSectionStart();
    int end = getSectionEnd();
    if (isBold) {
        edit.setSpan(new StyleSpan(Typeface.BOLD),
                star,
                end,
                Typeface.BOLD);
    } else {
        StyleSpan[] styleSpans = edit.getSpans(star,
                end, StyleSpan.class);
        for (CharacterStyle span : styleSpans) {
            if (span instanceof StyleSpan && ((StyleSpan) span).getStyle() == Typeface.BOLD)
                edit.removeSpan(span);
        }
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:23,代碼來源:RichEditText.java

示例8: setItalic

import android.text.Editable; //導入方法依賴的package包/類
void setItalic(boolean isItalic, int index) {
    if (index >= 0 && index < mSections.size()) {
        mSections.get(index).setItalic(isItalic);
    }
    Editable edit = getEditableText();
    int star = getSectionStart();
    int end = getSectionEnd();
    if (isItalic) {
        edit.setSpan(new StyleSpan(Typeface.ITALIC),
                star,
                end,
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else {
        StyleSpan[] styleSpans = edit.getSpans(star,
                end, StyleSpan.class);
        for (CharacterStyle span : styleSpans) {
            if (span instanceof StyleSpan && ((StyleSpan) span).getStyle() == Typeface.ITALIC)
                edit.removeSpan(span);
        }
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:22,代碼來源:RichEditText.java

示例9: setMidLine

import android.text.Editable; //導入方法依賴的package包/類
/**
 * 中橫線,即刪除線
 *
 * @param isMidLine isMidLine
 */
void setMidLine(boolean isMidLine) {
    int index = getSelectionIndex();
    if (index >= 0 && index < mSections.size()) {
        mSections.get(index).setMidLine(isMidLine);
    }
    Editable edit = getEditableText();
    int star = getSectionStart();
    int end = getSectionEnd();
    if (isMidLine) {
        edit.setSpan(new StrikethroughSpan(),
                star,
                end,
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else {
        StrikethroughSpan[] styleSpans = edit.getSpans(star,
                end, StrikethroughSpan.class);
        for (StrikethroughSpan span : styleSpans) {
            edit.removeSpan(span);
        }
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:27,代碼來源:RichEditText.java

示例10: endBlockElement

import android.text.Editable; //導入方法依賴的package包/類
private void endBlockElement(String tag, Editable text) {
    Newline n = getLast(text, Newline.class);
    if (n != null) {
        appendNewlines(text, n.mNumNewlines);
        text.removeSpan(n);
    }
    Alignment a = getLast(text, Alignment.class);
    if (a != null) {
        setSpanFromMark(tag, text, a, new AlignmentSpan.Standard(a.mAlignment));
    }
}
 
開發者ID:Pixplicity,項目名稱:HtmlCompat,代碼行數:12,代碼來源:HtmlToSpannedConverter.java

示例11: setTextSizeSpan

import android.text.Editable; //導入方法依賴的package包/類
private void setTextSizeSpan(int textSize, int index) {
    Editable edit = getEditableText();
    int star = getSectionStart(index);
    int end = getSectionEnd(index);
    if (star >= end)
        return;
    AbsoluteSizeSpan[] styleSpans = edit.getSpans(star, end, AbsoluteSizeSpan.class);
    for (AbsoluteSizeSpan span : styleSpans) {
        edit.removeSpan(span);
    }
    edit.setSpan(new AbsoluteSizeSpan(UI.dipToPx(getContext(), textSize)), star, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:13,代碼來源:RichEditText.java

示例12: setSpan

import android.text.Editable; //導入方法依賴的package包/類
/**
 * Adds the span to the current text.
 * @param userText The user entered text.
 * @param autocompleteText The autocomplete text being appended.
 */
public void setSpan(CharSequence userText, CharSequence autocompleteText) {
    Editable text = getText();
    text.removeSpan(this);
    mAutocompleteText = autocompleteText;
    mUserText = userText;
    text.setSpan(
            this,
            userText.length(),
            text.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:17,代碼來源:UrlBar.java

示例13: setColorSpan

import android.text.Editable; //導入方法依賴的package包/類
void setColorSpan(int color, int index) {
    Editable edit = getEditableText();
    int star = getSectionStart(index);
    int end = getSectionEnd(index);
    if (star >= end)
        return;
    ForegroundColorSpan[] styleSpans = edit.getSpans(star, end, ForegroundColorSpan.class);
    for (ForegroundColorSpan span : styleSpans) {
        edit.removeSpan(span);
    }
    edit.setSpan(new ForegroundColorSpan(color), star, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:13,代碼來源:RichEditText.java

示例14: redo

import android.text.Editable; //導入方法依賴的package包/類
/**
 * Perform redo.
 */
public void redo() {
    EditItem edit = mEditHistory.getNext();
    if (edit == null) {
        return;
    }

    Editable text = getEditableText();
    int start = edit.mmStart;
    int end = start + (edit.mmBefore != null
            ? edit.mmBefore.length() : 0);

    mIsUndoOrRedo = true;
    text.replace(start, end, edit.mmAfter);
    mIsUndoOrRedo = false;

    // This will get rid of underlines inserted when editor tries to come
    // up with a suggestion.
    for (Object o : text.getSpans(0,
            text.length(), UnderlineSpan.class)) {
        text.removeSpan(o);
    }

    Selection.setSelection(text,
            edit.mmAfter == null ? start
                    : (start + edit.mmAfter.length()));
}
 
開發者ID:ujjwalagrawal17,項目名稱:CodeCompilerApp,代碼行數:30,代碼來源:MainActivity.java

示例15: findClose

import android.text.Editable; //導入方法依賴的package包/類
private void findClose(char open, int selEnd) {
    Log.d(TAG, "findClose() called with: open = [" + open + "], selEnd = [" + selEnd + "]");

    Editable text = editText.getText();
    int cursor = selEnd + 1;
    int count = 1;
    char close = getClose(open);

    boolean find = false;
    while (cursor < text.length()) {
        char chatAtCursor = text.charAt(cursor);
        if (chatAtCursor == open) {
            count++;
        } else if (chatAtCursor == close) {
            count--;
        }
        if (count == 0) {
            find = true;
            break;
        }
        cursor++;
    }
    BracketSpan[] spans = text.getSpans(0, text.length(), BracketSpan.class);
    for (BracketSpan span : spans) {
        text.removeSpan(span);
    }
    text.setSpan(new BracketSpan(codeTheme.getBracketColor(),
            codeTheme.getTextColor()), selEnd, selEnd + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    if (find) {
        text.setSpan(new BracketSpan(codeTheme.getBracketColor(),
                codeTheme.getTextColor()), cursor, cursor + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:34,代碼來源:BracketHighlighter.java


注:本文中的android.text.Editable.removeSpan方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。