to top
Android APIs
public class

Selection

extends Object
java.lang.Object
   ↳ android.text.Selection

Class Overview

Utility class for manipulating cursors and selections in CharSequences. A cursor is a selection where the start and end are at the same offset.

Summary

Fields
public static final Object SELECTION_END
public static final Object SELECTION_START
Public Methods

? Examples
static boolean extendDown( Spannable text, Layout layout)
Move the selection end to the buffer offset physically below the current selection end.

? Examples
static boolean extendLeft( Spannable text, Layout layout)
Move the selection end to the buffer offset physically to the left of the current selection end.

? Examples
static boolean extendRight( Spannable text, Layout layout)
Move the selection end to the buffer offset physically to the right of the current selection end.

? Examples
final static void extendSelection( Spannable text, int index)
Move the selection edge to offset index.

? Examples
static boolean extendToLeftEdge( Spannable text, Layout layout)

? Examples
static boolean extendToRightEdge( Spannable text, Layout layout)

? Examples
static boolean extendUp( Spannable text, Layout layout)
Move the selection end to the buffer offset physically above the current selection end.

? Examples
final static int getSelectionEnd( CharSequence text)
Return the offset of the selection edge or cursor, or -1 if there is no selection or cursor.

? Examples
final static int getSelectionStart( CharSequence text)
Return the offset of the selection anchor or cursor, or -1 if there is no selection or cursor.

? Examples
static boolean moveDown( Spannable text, Layout layout)
Move the cursor to the buffer offset physically below the current offset, or return false if the cursor is already on the bottom line.

? Examples
static boolean moveLeft( Spannable text, Layout layout)
Move the cursor to the buffer offset physically to the left of the current offset, or return false if the cursor is already at the left edge of the line and there is not another line to move it to.

? Examples
static boolean moveRight( Spannable text, Layout layout)
Move the cursor to the buffer offset physically to the right of the current offset, or return false if the cursor is already at at the right edge of the line and there is not another line to move it to.

? Examples
static boolean moveToLeftEdge( Spannable text, Layout layout)

? Examples
static boolean moveToRightEdge( Spannable text, Layout layout)

? Examples
static boolean moveUp( Spannable text, Layout layout)
Move the cursor to the buffer offset physically above the current offset, or return false if the cursor is already on the top line.

? Examples
final static void removeSelection( Spannable text)
Remove the selection or cursor, if any, from the text.

? Examples
final static void selectAll( Spannable text)
Select the entire text.

? Examples
final static void setSelection( Spannable text, int index)
Move the cursor to offset index.

? Examples
static void setSelection( Spannable text, int start, int stop)
Set the selection anchor to start and the selection edge to stop.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

public static final Object SELECTION_END

Added in API level 1

public static final Object SELECTION_START

Added in API level 1

Public Methods

public static boolean extendDown (Spannable text, Layout layout)

Added in API level 1

Move the selection end to the buffer offset physically below the current selection end.

public static boolean extendLeft (Spannable text, Layout layout)

Added in API level 1

Move the selection end to the buffer offset physically to the left of the current selection end.

public static boolean extendRight (Spannable text, Layout layout)

Added in API level 1

Move the selection end to the buffer offset physically to the right of the current selection end.

public static final void extendSelection (Spannable text, int index)

Added in API level 1

Move the selection edge to offset index.

public static boolean extendToLeftEdge (Spannable text, Layout layout)

Added in API level 1

public static boolean extendToRightEdge (Spannable text, Layout layout)

Added in API level 1

public static boolean extendUp (Spannable text, Layout layout)

Added in API level 1

Move the selection end to the buffer offset physically above the current selection end.

public static final int getSelectionEnd (CharSequence text)

Added in API level 1

Return the offset of the selection edge or cursor, or -1 if there is no selection or cursor.

public static final int getSelectionStart (CharSequence text)

Added in API level 1

Return the offset of the selection anchor or cursor, or -1 if there is no selection or cursor.

public static boolean moveDown (Spannable text, Layout layout)

Added in API level 1

Move the cursor to the buffer offset physically below the current offset, or return false if the cursor is already on the bottom line.

public static boolean moveLeft (Spannable text, Layout layout)

Added in API level 1

Move the cursor to the buffer offset physically to the left of the current offset, or return false if the cursor is already at the left edge of the line and there is not another line to move it to.

public static boolean moveRight (Spannable text, Layout layout)

Added in API level 1

Move the cursor to the buffer offset physically to the right of the current offset, or return false if the cursor is already at at the right edge of the line and there is not another line to move it to.

public static boolean moveToLeftEdge (Spannable text, Layout layout)

Added in API level 1

public static boolean moveToRightEdge (Spannable text, Layout layout)

Added in API level 1

public static boolean moveUp (Spannable text, Layout layout)

Added in API level 1

Move the cursor to the buffer offset physically above the current offset, or return false if the cursor is already on the top line.

public static final void removeSelection (Spannable text)

Added in API level 1

Remove the selection or cursor, if any, from the text.

public static final void selectAll (Spannable text)

Added in API level 1

Select the entire text.

public static final void setSelection (Spannable text, int index)

Added in API level 1

Move the cursor to offset index.

public static void setSelection (Spannable text, int start, int stop)

Added in API level 1

Set the selection anchor to start and the selection edge to stop.

No examples for this method.
Frequently called with: [Clear]
Portions of this page are reproduced from work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License. The original page is available here.