Language

IInputConnectionExtensions.ReplaceText Method

Definition

Replace the specific range in the editor with suggested text.

public static bool ReplaceText(this Android.Views.InputMethods.IInputConnection self, int start, int end, string text, int newCursorPosition, Android.Views.InputMethods.TextAttribute? textAttribute);
static member ReplaceText : Android.Views.InputMethods.IInputConnection * int * int * string * int * Android.Views.InputMethods.TextAttribute -> bool

Parameters

self
IInputConnection

The input connection on which to call the method.

start
Int32

the character index where the replacement should start. Value is 0 or greater

end
Int32

the character index where the replacement should end. Value is 0 or greater

text
String

The replacement text. This value cannot be null.

newCursorPosition
Int32

the new cursor position around the text. If > 0, this is relative to the end of the text - 1; if <= 0, this is relative to the start of the text. So a value of 1 will always advance you to the position after the full text being inserted. Note that this means you can't position the cursor within the text.

textAttribute
TextAttribute

The extra information about the text. This value may be null.

Returns

The value returned by the input connection's character sequence overload.

Remarks

Replace the specific range in the editor with suggested text.

The default interface implementation calls finishComposingText(), setSelection(start, end), and then commitText(text, newCursorPosition, textAttribute) within a batch edit. An input connection can override this behavior.

Similar to setSelection(int, int), the order of start and end is not important. In effect, the region from start to end and the region from end to start is the same. Editor authors, be ready to accept a start that is greater than end.

Android reference for android.view.inputmethod.InputConnection.replaceText.

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