0

ここに画像の説明を入力

ImageSpan を含む EditText の一部を強調表示したいのですが、BackgroundSpan は ImageSpan には影響しません。関数について考えます:setSelection。EditText を強調表示したいが、選択したくない。

setSelection のソース コードから学ぶことができると思います。誰かが私を助けたり、setSelection のソース コードを提供してくれませんか?ここに画像の説明を入力

4

1 に答える 1

0

これらはソースコードです

  /**
     * Set the selection anchor to <code>start</code> and the selection edge
     * to <code>stop</code>.
     */
    public static void setSelection(Spannable text, int start, int stop) {
        // int len = text.length();
        // start = pin(start, 0, len);  XXX remove unless we really need it
        // stop = pin(stop, 0, len);

        int ostart = getSelectionStart(text);
        int oend = getSelectionEnd(text);

        if (ostart != start || oend != stop) {
            text.setSpan(SELECTION_START, start, start,
                         Spanned.SPAN_POINT_POINT|Spanned.SPAN_INTERMEDIATE);
            text.setSpan(SELECTION_END, stop, stop,
                         Spanned.SPAN_POINT_POINT);
        }
    }



   /**
     * Move the cursor to offset <code>index</code>.
     */
    public static final void setSelection(Spannable text, int index) {
        setSelection(text, index, index);
    }

ここで完全なソースを参照してください

于 2013-05-31T03:30:08.573 に答える