Android- Issue with Image Span Replacement in diff

2020-07-18 05:00发布

I Am adding the customized Clickable spans to my MultiAutoCompleteTextview. After adding 2 or more Contacts in That Edit Text. i am replacing the extra Spans to Image Span with Text Contains Count . My problem is that count is displaying different in lower end devices(i.e., 2.2) and higher end devices(i.e., 4.0). Please have a look into the below Pictures.

Higher End Devices. Higher End Devices it is looking like this

LOwer End Devices enter image description here

So problem with Higher end devices. each extra chip is replacing the count 2 times. Here is the code for replacing the extra chip PLease find it.

void createMoreChipPlainText() {

    Editable text = getText();
    int start = 0;
    int end = start;
    for (int i = 0; i < CHIP_LIMIT; i++) {
        end = movePastTerminators(mTokenizer.findTokenEnd(text, start));
        start = end; // move to the next token and get its end.
    }
    // Now, count total addresses.
    start = 0;
    int tokenCount = countTokens(text);
    MoreImageSpan moreSpan = createMoreSpan(tokenCount - CHIP_LIMIT);
    SpannableString chipText = new SpannableString(text.subSequence(end,
            text.length()));
    chipText.setSpan(moreSpan, 0, chipText.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    text.replace(end, text.length(), chipText);

    mMoreChip = moreSpan;
}

Is there any issue with replace method for editable class in android. Any one have any idea about this issue. please post your suggestions here

0条回答
登录 后发表回答