次の方法で共有


IInputConnection.SetComposingText Method

Definition

Overloads

SetComposingText(ICharSequence, Int32)

Replace the currently composing text with the given text, and set the new cursor position.

SetComposingText(ICharSequence, Int32, TextAttribute)

The variant of #setComposingText(CharSequence, int).

SetComposingText(String, Int32, TextAttribute)

The variant of #setComposingText(CharSequence, int).

SetComposingText(ICharSequence, Int32)

Replace the currently composing text with the given text, and set the new cursor position.

[Android.Runtime.Register("setComposingText", "(Ljava/lang/CharSequence;I)Z", "GetSetComposingText_Ljava_lang_CharSequence_IHandler:Android.Views.InputMethods.IInputConnectionInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public bool SetComposingText (Java.Lang.ICharSequence? text, int newCursorPosition);
[<Android.Runtime.Register("setComposingText", "(Ljava/lang/CharSequence;I)Z", "GetSetComposingText_Ljava_lang_CharSequence_IHandler:Android.Views.InputMethods.IInputConnectionInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member SetComposingText : Java.Lang.ICharSequence * int -> bool

Parameters

text
ICharSequence

The composing text with styles if necessary. If no style object attached to the text, the default style for composing text is used. See android.text.Spanned for how to attach style object to the text. android.text.SpannableString and android.text.SpannableStringBuilder are two implementations of the interface android.text.Spanned.

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, because the editor can make modifications to the text you are providing so it is not possible to correctly specify locations there.

Returns

true on success, false if the input connection is no longer valid.

Attributes

Remarks

Replace the currently composing text with the given text, and set the new cursor position. Any composing text set previously will be removed automatically.

If there is any composing span currently active, all characters that it comprises are removed. The passed text is added in its place, and a composing span is added to this text. If there is no composing span active, the passed text is added at the cursor position (removing selected characters first if any), and a composing span is added on the new text. Finally, the cursor is moved to the location specified by newCursorPosition.

This is usually called by IMEs to add or remove or change characters in the composing span. Calling this method will cause the editor to call android.inputmethodservice.InputMethodService#onUpdateSelection(int, int, int, int, int, int) on the current IME after the batch input is over.

<strong>Editor authors:</strong> please keep in mind the text may be very similar or completely different than what was in the composing span at call time, or there may not be a composing span at all. Please note that although it's not typical use, the string may be empty. Treat this normally, replacing the currently composing text with an empty string. Also, be careful with the cursor position. IMEs rely on this working exactly as described above. Since this changes the contents of the editor, you need to make the changes known to the input method by calling InputMethodManager#updateSelection(View, int, int, int, int), but be careful to wait until the batch edit is over if one is in progress. Note that this method can set the cursor position on either edge of the composing text or entirely outside it, but the IME may also go on to move the cursor position to within the composing text in a subsequent call so you should make no assumption at all: the composing text and the selection are entirely independent.

Java documentation for android.view.inputmethod.InputConnection.setComposingText(java.lang.CharSequence, 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

SetComposingText(ICharSequence, Int32, TextAttribute)

The variant of #setComposingText(CharSequence, int).

[Android.Runtime.Register("setComposingText", "(Ljava/lang/CharSequence;ILandroid/view/inputmethod/TextAttribute;)Z", "GetSetComposingText_Ljava_lang_CharSequence_ILandroid_view_inputmethod_TextAttribute_Handler:Android.Views.InputMethods.IInputConnection, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=33)]
public virtual bool SetComposingText (Java.Lang.ICharSequence text, int newCursorPosition, Android.Views.InputMethods.TextAttribute? textAttribute);
[<Android.Runtime.Register("setComposingText", "(Ljava/lang/CharSequence;ILandroid/view/inputmethod/TextAttribute;)Z", "GetSetComposingText_Ljava_lang_CharSequence_ILandroid_view_inputmethod_TextAttribute_Handler:Android.Views.InputMethods.IInputConnection, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=33)>]
abstract member SetComposingText : Java.Lang.ICharSequence * int * Android.Views.InputMethods.TextAttribute -> bool
override this.SetComposingText : Java.Lang.ICharSequence * int * Android.Views.InputMethods.TextAttribute -> bool

Parameters

text
ICharSequence

The composing text with styles if necessary. If no style object attached to the text, the default style for composing text is used. See android.text.Spanned for how to attach style object to the text. android.text.SpannableString and android.text.SpannableStringBuilder are two implementations of the interface android.text.Spanned.

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, because the editor can make modifications to the text you are providing so it is not possible to correctly specify locations there.

textAttribute
TextAttribute

The extra information about the text.

Returns

true on success, false if the input connection is no longer

Attributes

Remarks

The variant of #setComposingText(CharSequence, int). This method is used to allow the IME to provide extra information while setting up composing text.

Java documentation for android.view.inputmethod.InputConnection.setComposingText(java.lang.CharSequence, int, android.view.inputmethod.TextAttribute).

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

SetComposingText(String, Int32, TextAttribute)

The variant of #setComposingText(CharSequence, int).

public virtual bool SetComposingText (string text, int newCursorPosition, Android.Views.InputMethods.TextAttribute? textAttribute);
abstract member SetComposingText : string * int * Android.Views.InputMethods.TextAttribute -> bool
override this.SetComposingText : string * int * Android.Views.InputMethods.TextAttribute -> bool

Parameters

text
String

The composing text with styles if necessary. If no style object attached to the text, the default style for composing text is used. See android.text.Spanned for how to attach style object to the text. android.text.SpannableString and android.text.SpannableStringBuilder are two implementations of the interface android.text.Spanned.

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, because the editor can make modifications to the text you are providing so it is not possible to correctly specify locations there.

textAttribute
TextAttribute

The extra information about the text.

Returns

true on success, false if the input connection is no longer

Remarks

The variant of #setComposingText(CharSequence, int). This method is used to allow the IME to provide extra information while setting up composing text.

Java documentation for android.view.inputmethod.InputConnection.setComposingText(java.lang.CharSequence, int, android.view.inputmethod.TextAttribute).

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