共用方式為


IInputConnection.GetExtractedText(ExtractedTextRequest, GetTextFlags) Method

Definition

Retrieve the current text in the input connection's editor, and monitor for any changes to it.

[Android.Runtime.Register("getExtractedText", "(Landroid/view/inputmethod/ExtractedTextRequest;I)Landroid/view/inputmethod/ExtractedText;", "GetGetExtractedText_Landroid_view_inputmethod_ExtractedTextRequest_IHandler:Android.Views.InputMethods.IInputConnectionInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public Android.Views.InputMethods.ExtractedText? GetExtractedText (Android.Views.InputMethods.ExtractedTextRequest? request, Android.Views.InputMethods.GetTextFlags flags);
[<Android.Runtime.Register("getExtractedText", "(Landroid/view/inputmethod/ExtractedTextRequest;I)Landroid/view/inputmethod/ExtractedText;", "GetGetExtractedText_Landroid_view_inputmethod_ExtractedTextRequest_IHandler:Android.Views.InputMethods.IInputConnectionInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member GetExtractedText : Android.Views.InputMethods.ExtractedTextRequest * Android.Views.InputMethods.GetTextFlags -> Android.Views.InputMethods.ExtractedText

Parameters

request
ExtractedTextRequest

Description of how the text should be returned. android.view.inputmethod.ExtractedTextRequest

flags
GetTextFlags

Additional options to control the client, either 0 or #GET_EXTRACTED_TEXT_MONITOR.

Returns

an android.view.inputmethod.ExtractedText object describing the state of the text view and containing the extracted text itself, or null if the input connection is no longer valid of the editor can't comply with the request for some reason.

Attributes

Remarks

Retrieve the current text in the input connection's editor, and monitor for any changes to it. This function returns with the current text, and optionally the input connection can send updates to the input method when its text changes.

This method may fail either if the input connection has become invalid (such as its process crashing) or the client is taking too long to respond with the text (it is given a couple seconds to return). In either case, null is returned.

Editor authors: as a general rule, try to comply with the fields in request for how many chars to return, but if performance or convenience dictates otherwise, please feel free to do what is most appropriate for your case. Also, if the #GET_EXTRACTED_TEXT_MONITOR flag is set, you should be calling InputMethodManager#updateExtractedText(View, int, ExtractedText) whenever you call InputMethodManager#updateSelection(View, int, int, int, int).

Java documentation for android.view.inputmethod.InputConnection.getExtractedText(android.view.inputmethod.ExtractedTextRequest, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to