다음을 통해 공유


Bidi.GetVisualRun(Int32) Method

Definition

Get a BidiRun object according to its index.

[Android.Runtime.Register("getVisualRun", "(I)Landroid/icu/text/BidiRun;", "GetGetVisualRun_IHandler", ApiSince=29)]
public virtual Android.Icu.Text.BidiRun? GetVisualRun (int runIndex);
[<Android.Runtime.Register("getVisualRun", "(I)Landroid/icu/text/BidiRun;", "GetGetVisualRun_IHandler", ApiSince=29)>]
abstract member GetVisualRun : int -> Android.Icu.Text.BidiRun
override this.GetVisualRun : int -> Android.Icu.Text.BidiRun

Parameters

runIndex
Int32

is the number of the run in visual order, in the range [0..countRuns()-1].

Returns

a BidiRun object containing the details of the run. The directionality of the run is LTR==0 or RTL==1, never MIXED.

Attributes

Remarks

Get a BidiRun object according to its index. BidiRun methods may be used to retrieve the run's logical start, length and level, which can be even for an LTR run or odd for an RTL run. In an RTL run, the character at the logical start is visually on the right of the displayed run. The length is the number of characters in the run.

countRuns() is normally called before the runs are retrieved.

Example:

Bidi bidi = new Bidi();
             String text = "abc 123 DEFG xyz";
             bidi.setPara(text, Bidi.RTL, null);
             int i, count=bidi.countRuns(), logicalStart, visualIndex=0, length;
             BidiRun run;
             for (i = 0; i &lt; count; ++i) {
                 run = bidi.getVisualRun(i);
                 logicalStart = run.getStart();
                 length = run.getLength();
                 if (Bidi.LTR == run.getEmbeddingLevel()) {
                     do { // LTR
                         show_char(text.charAt(logicalStart++), visualIndex++);
                     } while (--length &gt; 0);
                 } else {
                     logicalStart += length;  // logicalLimit
                     do { // RTL
                         show_char(text.charAt(--logicalStart), visualIndex++);
                     } while (--length &gt; 0);
                 }
             }

Note that in right-to-left runs, code like this places second surrogates before first ones (which is generally a bad idea) and combining characters before base characters.

Use of {@link #writeReordered}, optionally with the {@link #KEEP_BASE_COMBINING} option, can be considered in order to avoid these issues.

Java documentation for android.icu.text.Bidi.getVisualRun(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