0

RichTextEditor内部クラスを持つクラスを作成していRichTextEditorTextWatcherます。e.getSpans画面に表示されているものと、内部で呼び出したときに得られるものとの間に矛盾がありますbeforeTextChanged

画面上に、スタイルが適用されていないテキスト (私の場合は 1 文字) が表示されますが、e.getSpans()実際には、呼び出しは太字スタイルが適用されていることを示しています。

これは既知の Android バグですか?

public class RichTextEditor extends AppCompatEditText  
{

    // other code not shown

    public class RichTextEditorTextWatcher implements TextWatcher
    {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after)
        {
            if (after == 0) //deletion occurred
            {
                isDeletion = true;
                Editable e = RichTextEditor.this.getText();

                /** The next line is the problematic line!
                  * this.prevStyles returns a StyleSpan (bold) even when I don't see it on the screen for that character.
                  */
                this.prevStyles = e.getSpans(start, start+count, CharacterStyle.class); 

                for (CharacterStyle c : this.prevStyles)
                {
                    if (c instanceof StyleSpan)
                    {
                        if (((StyleSpan)c).getStyle() == Typeface.BOLD) 
                            boldButton.setChecked(true);
                        else
                            boldButton.setChecked(false);
                    }
                }
            }
            else
                isDeletion = false;
        }
    }
}
4

0 に答える 0