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


Java Editable.append方法代码示例

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


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

示例1: handleTag

import android.text.Editable; //导入方法依赖的package包/类
@Override
public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader) {
    if (tag.equals("ul")) {
        if (opening) {
            char lastChar = 0;
            if (output.length() > 0) {
                lastChar = output.charAt(output.length() - 1);
            }
            if (lastChar != '\n') {
                output.append("\r\n");
            }
        } else {
            output.append("\r\n");
        }
    }

    if (tag.equals("li")) {
        if (opening) {
            output.append("\t•  ");
        } else {
            output.append("\r\n");
        }
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:25,代码来源:HtmlConverter.java

示例2: startTag

import android.text.Editable; //导入方法依赖的package包/类
private void startTag(String tag, Editable out, XMLReader reader) {
    switch (tag.toLowerCase()) {
        case "ul":
            list.push(true);
            out.append('\n');
            break;
        case "ol":
            list.push(false);
            out.append('\n');
            break;
        case "pre":
            break;
        default:
            break;
    }
}
 
开发者ID:nichbar,项目名称:Aequorea,代码行数:17,代码来源:HtmlTagHandler.java

示例3: getUnmaskedText

import android.text.Editable; //导入方法依赖的package包/类
public String getUnmaskedText() {
    Editable text = super.getText();
    if (mask != null && !mask.isEmpty()) {
        Editable unMaskedText = new SpannableStringBuilder();
        for (Integer index : listValidCursorPositions) {
            if (text != null) {
                unMaskedText.append(text.charAt(index));
            }
        }
        if (format != null && !format.isEmpty())
            return formatText(unMaskedText.toString(), format);
        else
            return unMaskedText.toString().trim();
    }

    return text.toString().trim();
}
 
开发者ID:msayan,项目名称:star-dns-changer,代码行数:18,代码来源:MaskedEditText.java

示例4: setupUserAutocomplete

import android.text.Editable; //导入方法依赖的package包/类
private void setupUserAutocomplete() {
    EditText edit = (EditText) findViewById(R.id.single);
    float elevation = 6f;
    Drawable backgroundDrawable = new ColorDrawable(Color.WHITE);
    AutocompletePresenter<User> presenter = new UserPresenter(this);
    AutocompleteCallback<User> callback = new AutocompleteCallback<User>() {
        @Override
        public boolean onPopupItemClicked(Editable editable, User item) {
            editable.clear();
            editable.append(item.getFullname());
            return true;
        }

        public void onPopupVisibilityChanged(boolean shown) {}
    };

    userAutocomplete = Autocomplete.<User>on(edit)
            .with(elevation)
            .with(backgroundDrawable)
            .with(presenter)
            .with(callback)
            .build();
}
 
开发者ID:natario1,项目名称:Autocomplete,代码行数:24,代码来源:MainActivity.java

示例5: startImg

import android.text.Editable; //导入方法依赖的package包/类
private void startImg(Editable text, Attributes attributes, HtmlCompat.ImageGetter img) {
    String src = attributes.getValue("", "src");
    Drawable d = null;
    if (img != null) {
        d = img.getDrawable(src, attributes);
    }
    if (d == null) {
        Resources res = mContext.getResources();
        d = res.getDrawable(R.drawable.unknown_image);
        d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
    }
    int len = text.length();
    text.append("\uFFFC");
    text.setSpan(new ImageSpan(d, src), len, text.length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
 
开发者ID:Pixplicity,项目名称:HtmlCompat,代码行数:17,代码来源:HtmlToSpannedConverter.java

示例6: applyMask

import android.text.Editable; //导入方法依赖的package包/类
private void applyMask(Editable text) {
    if (TextUtils.isEmpty(text) || !hasMask()) {
        return;
    }

    //remove input filters to ignore input type
    InputFilter[] filters = text.getFilters();
    text.setFilters(new InputFilter[0]);

    int maskLen = mask.length();
    int textLen = text.length();

    int i = 0;
    int notSymbolIndex = 0;
    StringBuilder sb = new StringBuilder();
    while (i < maskLen && notSymbolIndex < textLen) {
        if (mask.charAt(i) == text.charAt(notSymbolIndex) || mask.charAt(i) == REPLACE_CHAR) {
            sb.append(text.charAt(notSymbolIndex));
            notSymbolIndex++;
        } else {
            sb.append(mask.charAt(i));
        }
        i++;
    }

    text.clear();
    text.append(sb.toString());

    //reset filters
    text.setFilters(filters);
}
 
开发者ID:santalu,项目名称:mask-edittext,代码行数:32,代码来源:MaskEditText.java

示例7: handleTag

import android.text.Editable; //导入方法依赖的package包/类
@Override
public void handleTag(boolean opening, String tag, Editable output,
                      XMLReader reader) {
    switch (tag) {
        case "ul":
            if (opening) {
                listNum = -1;
            } else {
                output.append('\n');
            }
            break;
        case "ol":
            if (opening) {
                listNum = 1;
            } else {
                output.append('\n');
            }
            break;
        case "li":
            if (opening) {
                if (listNum == -1) {
                    output.append("\t• ");
                } else {
                    output.append("\t").append(Integer.toString(listNum)).append(". ");
                    listNum++;
                }
            } else {
                output.append('\n');
            }
            break;
    }
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:33,代码来源:Utils.java

示例8: reallyHandler

import android.text.Editable; //导入方法依赖的package包/类
private void reallyHandler(int start, int end, String tag, Editable out, XMLReader reader) {
    switch (tag.toLowerCase()) {
        case "ol":
        case "ul":
            out.append('\n');
            if (!list.isEmpty())
                list.pop();
            break;
        default:
            break;
    }
}
 
开发者ID:nichbar,项目名称:Aequorea,代码行数:13,代码来源:HtmlTagHandler.java

示例9: end

import android.text.Editable; //导入方法依赖的package包/类
/**
 * Modified from {@link android.text.Html}
 */
private void end(Editable output, Class kind, boolean paragraphStyle, Object... replaces) {
    Object obj = getLast(output, kind);
    // start of the tag
    int where = output.getSpanStart(obj);
    // end of the tag
    int len = output.length();

    // If we're in a table, then we need to store the raw HTML for later
    if (tableTagLevel > 0) {
        final CharSequence extractedSpanText = extractSpanText(output, kind);
        tableHtmlBuilder.append(extractedSpanText);
    }

    output.removeSpan(obj);

    if (where != len) {
        int thisLen = len;
        // paragraph styles like AlignmentSpan need to end with a new line!
        if (paragraphStyle) {
            output.append("\n");
            thisLen++;
        }
        for (Object replace : replaces) {
            output.setSpan(replace, where, thisLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        if (HtmlTextView.DEBUG) {
            Log.d(HtmlTextView.TAG, "where: " + where);
            Log.d(HtmlTextView.TAG, "thisLen: " + thisLen);
        }
    }
}
 
开发者ID:RanKKI,项目名称:PSNine,代码行数:36,代码来源:HtmlTagHandler.java

示例10: insertAtEnd

import android.text.Editable; //导入方法依赖的package包/类
private static int insertAtEnd(EditTextSelectionState selectionState,
                               CharSequence textToInsert) {
    Editable editableText = selectionState.getEditText().getEditableText();
    int insertPos = editableText.length();
    editableText.append(textToInsert);
    return insertPos;
}
 
开发者ID:TryGhost,项目名称:Ghost-Android,代码行数:8,代码来源:EditTextUtils.java

示例11: setTagData

import android.text.Editable; //导入方法依赖的package包/类
private void setTagData(List<String> nameList) {
    LayoutInflater inflater = getLayoutInflater();
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.setMargins(Utils.dip2px(this, 15), 0, Utils.dip2px(this, 10), 0);
    LinearLayout.LayoutParams paramsFull = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    paramsFull.setMargins(Utils.dip2px(this, 15), 0, 0,Utils.dip2px(this, 10));

    View.OnClickListener onTagClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String tagString = (String) v.getTag();
            Editable editable = mRemarksEditText.getEditableText();
            int index = mRemarksEditText.getSelectionStart();
            SpannableStringBuilder spanny = new SpannableStringBuilder();
            spanny.append(tagString);

            if (index < 0 || index >= editable.length()) {
                editable.append(spanny);
            } else {
                //insert the words in where the cursor is.
                editable.insert(index, spanny);
            }
        }
    };
    for (String itemTag : nameList) {
        String formatTag = Constants.TAG_FLAG + itemTag + Constants.TAG_FLAG;
        TextView tag = (TextView) inflater.inflate(R.layout.tag_item, null);
        tag.setText(itemTag);
        tag.setTag(formatTag);
        tag.setOnClickListener(onTagClickListener);
        tagBarContent.addView(tag, params);

        TextView tag2 = (TextView) inflater.inflate(R.layout.tag_item, null);
        tag2.setText(itemTag);
        tag2.setTag(formatTag);
        tag2.setOnClickListener(onTagClickListener);
        tagFullContainer.addView(tag2, paramsFull);

    }
}
 
开发者ID:hosle,项目名称:HTagEditor,代码行数:41,代码来源:MainActivity.java

示例12: endCode

import android.text.Editable; //导入方法依赖的package包/类
private void endCode(Editable output, XMLReader xmlReader) {
    output.append(" ");
    int code_end = output.length();
    output.setSpan(new ForegroundColorSpan(Color.parseColor("#f44336")), code_start, code_end, Spannable.SPAN_MARK_MARK);
    output.setSpan(new BackgroundColorSpan(Color.parseColor("#ffebee")), code_start, code_end, Spannable.SPAN_MARK_MARK);
    //output.append(" ");
}
 
开发者ID:GitaiQAQ,项目名称:AboutView,代码行数:8,代码来源:BaseCustomTagHandler.java

示例13: insertTextToEditText

import android.text.Editable; //导入方法依赖的package包/类
private void insertTextToEditText(String txt) {
    if (TextUtils.isEmpty(txt)) return;
    int start = mEditText.getSelectionStart();
    int end = mEditText.getSelectionEnd();
    Editable edit = mEditText.getEditableText();//获取EditText的文字
    if (start < 0 || start >= edit.length()) {
        edit.append(txt);
    } else {
        edit.replace(start, end, txt);//光标所在位置插入文字
    }
}
 
开发者ID:swustmuzi,项目名称:SoftKeyboardTopTool,代码行数:12,代码来源:MainActivity.java

示例14: afterTextChanged

import android.text.Editable; //导入方法依赖的package包/类
@Override
public void afterTextChanged(Editable s) {
    removeTextChangedListener(this);

    if (s.length() == 1 && s.charAt(0) > '1') {
        s.insert(0, "0");
    }

    if (s.length() == 2 && !deleted) {
        if (s.toString().matches("\\d[^\\d]")) {
            s.insert(0, "0");
        } else if (!s.toString().matches("\\d*[^\\d]\\d*")) {
            s.append(SEPARATOR_CHAR);
        }
    }

    for (int i = 0; i < s.length(); i++) {
        char c = s.charAt(i);

        if (i == 2) {
            if (c != SEPARATOR_CHAR) {
                if (!Character.isDigit(c)) {
                    s.replace(i, i + 1, separatorString);
                } else {
                    s.insert(i, separatorString);

                    if (deleted) {
                        int selectionStart = getSelectionStart();
                        int selectionEnd = getSelectionEnd();
                        int newSelectionStart = selectionStart - 1 == i ? selectionStart - 1 : selectionStart;
                        int newSelectionEnd = selectionEnd - 1 == i ? selectionEnd - 1 : selectionEnd;
                        setSelection(newSelectionStart, newSelectionEnd);
                    }
                }
            }
        } else {
            if (!Character.isDigit(c)) {
                s.delete(i, i + 1);
            }
        }
    }

    boolean inputDateValid = isInputDateValid(s.toString());

    if (validator != null) {
        validator.setReady(ExpiryDateEditText.this, inputDateValid);
    }

    if (inputDateValid) {
        View next = focusSearch(View.FOCUS_RIGHT);
        if (next != null) {
            next.requestFocus();
        }
    }

    addTextChangedListener(this);
}
 
开发者ID:Adyen,项目名称:adyen-android,代码行数:58,代码来源:ExpiryDateEditText.java

示例15: acceptSpace

import android.text.Editable; //导入方法依赖的package包/类
public boolean acceptSpace(int space) {
    // This can happen, I don't know, let's consume.
    if (!mView.isLaidOut()) return true;

    String logPrefix = logPrefix();
    // Returning FALSE means that the pager will try to:
    // 1. Pass the first view of this page to the previous page
    //    ^ FIXED THIS IN THE PAGER. It won't happen.
    // 2. Accept the first view of the nextView page at the end of this page
    //
    // So if we are not last(), we must ensure we never return FALSE.
    // That is, if !isLast(), return true. This is well handler here.

    int height = mView.getLayout().getHeight();
    int target = height + space;
    LOG.w(logPrefix, "acceptSpace:", "asked to accept:", space, "height:", height, "target:", target);
    if (isLast()) {
        // No one to accept from. We can safely return false. The pager will not try to move
        // us to the previous page, due to specific behavior for AutoSplitViews.
        LOG.w(logPrefix, "acceptSpace:", "quick end because we are the last. Returning false");
        return false;
    }

    if (mPost.length() == 0) {
        // Next view is empty. Remove it and try again with the following. Should be null though.
        LOG.w(logPrefix, "acceptSpace:", "quick end: nextView view empty, removing.");
        removeFromChain(mPost);
        return acceptSpace(space);
    }

    setActionInProgress(true);
    Editable source = edit(mPost);
    Editable dest = edit(mView);
    Pattern pattern = Pattern.compile("\\s"); // TODO: We only support ' ' and '\n', don't catch others
    CharSequence word = "";
    int wordCount = 0;
    while (mView.getLayout().getHeight() <= target) {
        if (source.length() == 0) break;
        Matcher matcher = pattern.matcher(source);
        int end;
        if (matcher.find()) {
            end = matcher.end();
            if (end > 1 && source.charAt(end - 1) == '\n') {
                end--;
            }
        } else {
            end = source.length();
        }
        word = source.subSequence(0, end);
        LOG.v(logPrefix, "acceptSpace:", "Found!", "end:", end, "word:(" + word + ")");
        source.replace(0, end, "");
        dest.append(word);
        wordCount++;
    }

    // The while loops ends when the source is empty, or when we took to much.
    if (mView.getLayout().getHeight() > target) {
        LOG.i(logPrefix, "acceptSpace:", "Out of the loop. We took to much. Returning word:", word);
        dest.replace(dest.length() - word.length(), dest.length(), "");
        source.insert(0, word);
        wordCount--;
    }

    setActionInProgress(false);
    if (mPost.length() == 0) {
        LOG.w(logPrefix, "acceptSpace:", "We took everything from post view. Removing.", next().isLast());
        // View is empty. Remove it, and try again with the nextView mPost.
        // This is a bit flaky, I should think more about it.
        removeFromChain(mPost);
        int remaining = target - mView.getLayout().getHeight(); // >= 0
        return acceptSpace(remaining);
    } else {
        // Post is not empty, but if we take something else, we take too much.
        // I would say that we can return true here.
        LOG.i(logPrefix, "acceptSpace:", "ENDED.", "words:", wordCount, "finalHeight:", mView.getLayout().getHeight());
        return true;
    }
}
 
开发者ID:natario1,项目名称:ViewPrinter,代码行数:79,代码来源:AutoSplitTextHelper.java


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