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


Java ExtractedText.FLAG_SINGLE_LINE屬性代碼示例

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


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

示例1: getSampleExtractedText

private ExtractedText getSampleExtractedText() {
    ExtractedText et = new ExtractedText();
    et.flags = ExtractedText.FLAG_SINGLE_LINE;
    et.text = "Hello world!";
    et.startOffset = 0;
    et.partialStartOffset = -1;
    et.selectionStart = et.text.length();
    et.selectionEnd = et.text.length();
    return et;
}
 
開發者ID:google,項目名稱:brailleback,代碼行數:10,代碼來源:BrailleIMETest.java

示例2: convertToExtractedText

private ExtractedText convertToExtractedText(TextInputState textInputState) {
    if (textInputState == null) return null;
    ExtractedText extractedText = new ExtractedText();
    extractedText.text = textInputState.text();
    extractedText.partialEndOffset = textInputState.text().length();
    // Set the partial start offset to -1 because the content is the full text.
    // See: Android documentation for ExtractedText#partialStartOffset
    extractedText.partialStartOffset = -1;
    extractedText.selectionStart = textInputState.selection().start();
    extractedText.selectionEnd = textInputState.selection().end();
    extractedText.flags = textInputState.singleLine() ? ExtractedText.FLAG_SINGLE_LINE : 0;
    return extractedText;
}
 
開發者ID:mogoweb,項目名稱:365browser,代碼行數:13,代碼來源:ThreadedInputConnection.java

示例3: extractTextInternal

boolean extractTextInternal(ExtractedTextRequest request, ExtractedText outText) {

        Component txtCmp = Display.getInstance().getCurrent().getFocused();
        if (txtCmp != null && txtCmp instanceof TextField) {
            String txt = ((TextField) txtCmp).getText();
            int partialStartOffset = -1;
            int partialEndOffset = -1;
            final CharSequence content = txt;
            if (content != null) {
                final int N = content.length();
                outText.partialStartOffset = outText.partialEndOffset = -1;
                partialStartOffset = 0;
                partialEndOffset = N;

                if ((request.flags & InputConnection.GET_TEXT_WITH_STYLES) != 0) {
                    outText.text = content.subSequence(partialStartOffset,
                            partialEndOffset);
                } else {
                    outText.text = TextUtils.substring(content, partialStartOffset,
                            partialEndOffset);
                }

                outText.flags = 0;
                outText.flags |= ExtractedText.FLAG_SINGLE_LINE;
                outText.startOffset = 0;
                outText.selectionStart = Selection.getSelectionStart(content);
                outText.selectionEnd = Selection.getSelectionEnd(content);
                return true;
            }

        }
        return false;
    }
 
開發者ID:codenameone,項目名稱:CodenameOne,代碼行數:33,代碼來源:CodenameOneInputConnection.java

示例4: getExtractedText

/**
 * @see BaseInputConnection#getExtractedText(android.view.inputmethod.ExtractedTextRequest,
 *                                           int)
 */
@Override
public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) {
    if (DEBUG) Log.w(TAG, "getExtractedText");
    ExtractedText et = new ExtractedText();
    Editable editable = getEditable();
    et.text = editable.toString();
    et.partialEndOffset = editable.length();
    et.selectionStart = Selection.getSelectionStart(editable);
    et.selectionEnd = Selection.getSelectionEnd(editable);
    et.flags = mSingleLine ? ExtractedText.FLAG_SINGLE_LINE : 0;
    return et;
}
 
開發者ID:openresearch,項目名稱:android-chromium-view,代碼行數:16,代碼來源:AdapterInputConnection.java

示例5: extractTextInternal

boolean extractTextInternal(ExtractedTextRequest request,
        int partialStartOffset, int partialEndOffset, int delta,
        ExtractedText outText) {
    final CharSequence content = mText;
    if (content != null) {
        if (partialStartOffset != EXTRACT_NOTHING) {
            final int N = content.length();
            if (partialStartOffset < 0) {
                outText.partialStartOffset = outText.partialEndOffset = -1;
                partialStartOffset = 0;
                partialEndOffset = N;
            } else {
                // Adjust offsets to ensure we contain full spans.
                if (content instanceof Spanned) {
                    Spanned spanned = (Spanned)content;
                    Object[] spans = spanned.getSpans(partialStartOffset,
                            partialEndOffset, ParcelableSpan.class);
                    int i = spans.length;
                    while (i > 0) {
                        i--;
                        int j = spanned.getSpanStart(spans[i]);
                        if (j < partialStartOffset) partialStartOffset = j;
                        j = spanned.getSpanEnd(spans[i]);
                        if (j > partialEndOffset) partialEndOffset = j;
                    }
                }
                outText.partialStartOffset = partialStartOffset;
                outText.partialEndOffset = partialEndOffset;
                // Now use the delta to determine the actual amount of text
                // we need.
                partialEndOffset += delta;
                if (partialStartOffset > N) {
                    partialStartOffset = N;
                } else if (partialStartOffset < 0) {
                    partialStartOffset = 0;
                }
                if (partialEndOffset > N) {
                    partialEndOffset = N;
                } else if (partialEndOffset < 0) {
                    partialEndOffset = 0;
                }
            }
            if ((request.flags&InputConnection.GET_TEXT_WITH_STYLES) != 0) {
                outText.text = content.subSequence(partialStartOffset,
                        partialEndOffset);
            } else {
                outText.text = TextUtils.substring(content, partialStartOffset,
                        partialEndOffset);
            }
        } else {
            outText.partialStartOffset = 0;
            outText.partialEndOffset = 0;
            outText.text = "";
        }
        outText.flags = 0;
        if (JotaTextKeyListener.getMetaStateSelecting(mText) != 0) {
            outText.flags |= ExtractedText.FLAG_SELECTING;
        }
        if (mSingleLine) {
            outText.flags |= ExtractedText.FLAG_SINGLE_LINE;
        }
        outText.startOffset = 0;
        outText.selectionStart = getSelectionStart();
        outText.selectionEnd = getSelectionEnd();
        return true;
    }
    return false;
}
 
開發者ID:jiro-aqua,項目名稱:JotaTextEditor,代碼行數:68,代碼來源:TextView.java


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