BaseMovementMethod


public class BaseMovementMethod
extends Object implements MovementMethod

java.lang.Object
   ↳ android.text.method.BaseMovementMethod


Base classes for movement methods.

Summary

Public constructors

BaseMovementMethod()

Public methods

boolean canSelectArbitrarily()

Returns true if this movement method allows arbitrary selection of any text; false if it has no selection (like a movement method that only scrolls) or a constrained selection (for example limited to links.

void initialize(TextView widget, Spannable text)
boolean nextParagraph(TextView widget, Spannable buffer)

Performs a next paragraph movement action.

boolean onGenericMotionEvent(TextView widget, Spannable text, MotionEvent event)
boolean onKeyDown(TextView widget, Spannable text, int keyCode, KeyEvent event)
boolean onKeyOther(TextView widget, Spannable text, KeyEvent event)

If the key listener wants to other kinds of key events, return true, otherwise return false and the caller (i.e.

boolean onKeyUp(TextView widget, Spannable text, int keyCode, KeyEvent event)
void onTakeFocus(TextView widget, Spannable text, int direction)
boolean onTouchEvent(TextView widget, Spannable text, MotionEvent event)
boolean onTrackballEvent(TextView widget, Spannable text, MotionEvent event)
boolean previousParagraph(TextView widget, Spannable buffer)

Performs a previous paragraph movement action.

Protected methods

boolean bottom(TextView widget, Spannable buffer)

Performs a bottom movement action.

boolean down(TextView widget, Spannable buffer)

Performs a down movement action.

boolean end(TextView widget, Spannable buffer)

Performs an end movement action.

int getMovementMetaState(Spannable buffer, KeyEvent event)

Gets the meta state used for movement using the modifiers tracked by the text buffer as well as those present in the key event.

boolean handleMovementKey(TextView widget, Spannable buffer, int keyCode, int movementMetaState, KeyEvent event)

Performs a movement key action.

boolean home(TextView widget, Spannable buffer)

Performs a home movement action.

boolean left(TextView widget, Spannable buffer)

Performs a left movement action.

boolean lineEnd(TextView widget, Spannable buffer)

Performs a line-end movement action.

boolean lineStart(TextView widget, Spannable buffer)

Performs a line-start movement action.

boolean pageDown(TextView widget, Spannable buffer)

Performs a page-down movement action.

boolean pageUp(TextView widget, Spannable buffer)

Performs a page-up movement action.

boolean right(TextView widget, Spannable buffer)

Performs a right movement action.

boolean top(TextView widget, Spannable buffer)

Performs a top movement action.

boolean up(TextView widget, Spannable buffer)

Performs an up movement action.

Inherited methods

Public constructors

BaseMovementMethod

public BaseMovementMethod ()

Public methods

canSelectArbitrarily

Added in API level 11
public boolean canSelectArbitrarily ()

Returns true if this movement method allows arbitrary selection of any text; false if it has no selection (like a movement method that only scrolls) or a constrained selection (for example limited to links. The "Select All" menu item is disabled if arbitrary selection is not allowed.

Returns
boolean

initialize

Added in API level 11
public void initialize (TextView widget, 
                Spannable text)

Parameters
widget TextView

text Spannable

nextParagraph

Added in API level 34
public boolean nextParagraph (TextView widget, 
                Spannable buffer)

Performs a next paragraph movement action.

Parameters
widget TextView: the text view This value cannot be null.

buffer Spannable: the text buffer This value cannot be null.

Returns
boolean true if the event was handled, otherwise false.

onGenericMotionEvent

Added in API level 12
public boolean onGenericMotionEvent (TextView widget, 
                Spannable text, 
                MotionEvent event)

Parameters
widget TextView

text Spannable

event MotionEvent

Returns
boolean

onKeyDown

Added in API level 11
public boolean onKeyDown (TextView widget, 
                Spannable text, 
                int keyCode, 
                KeyEvent event)

Parameters
widget TextView

text Spannable

keyCode int

event KeyEvent

Returns
boolean

onKeyOther

Added in API level 11
public boolean onKeyOther (TextView widget, 
                Spannable text, 
                KeyEvent event)

If the key listener wants to other kinds of key events, return true, otherwise return false and the caller (i.e. the widget host) will handle the key.

Parameters
widget TextView

text Spannable

event KeyEvent

Returns
boolean

onKeyUp

Added in API level 11
public boolean onKeyUp (TextView widget, 
                Spannable text, 
                int keyCode, 
                KeyEvent event)

Parameters
widget TextView

text Spannable

keyCode int

event KeyEvent

Returns
boolean

onTakeFocus

Added in API level 11
public void onTakeFocus (TextView widget, 
                Spannable text, 
                int direction)

Parameters
widget TextView

text Spannable

direction int

onTouchEvent

Added in API level 11
public boolean onTouchEvent (TextView widget, 
                Spannable text, 
                MotionEvent event)

Parameters
widget TextView

text Spannable

event MotionEvent

Returns
boolean

onTrackballEvent

Added in API level 11
public boolean onTrackballEvent (TextView widget, 
                Spannable text, 
                MotionEvent event)

Parameters
widget TextView

text Spannable

event MotionEvent

Returns
boolean

previousParagraph

Added in API level 34
public boolean previousParagraph (TextView widget, 
                Spannable buffer)

Performs a previous paragraph movement action.

Parameters
widget TextView: the text view This value cannot be null.

buffer Spannable: the text buffer This value cannot be null.

Returns
boolean true if the event was handled, otherwise false.

Protected methods

bottom

Added in API level 11
protected boolean bottom (TextView widget, 
                Spannable buffer)

Performs a bottom movement action. Moves the cursor or scrolls to the bottom of the buffer.

Parameters
widget TextView: The text view.

buffer Spannable: The text buffer.

Returns
boolean True if the event was handled.

down

Added in API level 11
protected boolean down (TextView widget, 
                Spannable buffer)

Performs a down movement action. Moves the cursor or scrolls down by one line.

Parameters
widget TextView: The text view.

buffer Spannable: The text buffer.

Returns
boolean True if the event was handled.

end

Added in API level 11
protected boolean end (TextView widget, 
                Spannable buffer)

Performs an end movement action. Moves the cursor or scrolls to the start of the line or to the top of the document depending on whether the insertion point is being moved or the document is being scrolled.

Parameters
widget TextView: The text view.

buffer Spannable: The text buffer.

Returns
boolean True if the event was handled.

getMovementMetaState

Added in API level 11
protected int getMovementMetaState (Spannable buffer, 
                KeyEvent event)

Gets the meta state used for movement using the modifiers tracked by the text buffer as well as those present in the key event. The movement meta state excludes the state of locked modifiers or the SHIFT key since they are not used by movement actions (but they may be used for selection).

Parameters
buffer Spannable: The text buffer.

event KeyEvent: The key event.

Returns
int The keyboard meta states used for movement.

handleMovementKey

Added in API level 11
protected boolean handleMovementKey (TextView widget, 
                Spannable buffer, 
                int keyCode, 
                int movementMetaState, 
                KeyEvent event)

Performs a movement key action. The default implementation decodes the key down and invokes movement actions such as down(TextView, Spannable) and up(TextView, Spannable). onKeyDown(android.widget.TextView, android.text.Spannable, int, android.view.KeyEvent) calls this method once to handle an KeyEvent#ACTION_DOWN. onKeyOther(android.widget.TextView, android.text.Spannable, android.view.KeyEvent) calls this method repeatedly to handle each repetition of an KeyEvent#ACTION_MULTIPLE.

Parameters
widget TextView: The text view.

buffer Spannable: The text buffer.

keyCode int: The key code.

movementMetaState int: The keyboard meta states used for movement.

event KeyEvent: The key event.

Returns
boolean True if the event was handled.

home

Added in API level 11
protected boolean home (TextView widget, 
                Spannable buffer)

Performs a home movement action. Moves the cursor or scrolls to the start of the line or to the top of the document depending on whether the insertion point is being moved or the document is being scrolled.

Parameters
widget TextView: The text view.

buffer Spannable: The text buffer.

Returns
boolean True if the event was handled.

left

Added in API level 11
protected boolean left (TextView widget, 
                Spannable buffer)

Performs a left movement action. Moves the cursor or scrolls left by one character.

Parameters
widget TextView: The text view.

buffer Spannable: The text buffer.

Returns
boolean True if the event was handled.

lineEnd

Added in API level 11
protected boolean lineEnd (TextView widget, 
                Spannable buffer)

Performs a line-end movement action. Moves the cursor or scrolls to the end of the line.

Parameters
widget TextView: The text view.

buffer Spannable: The text buffer.

Returns
boolean True if the event was handled.

lineStart

Added in API level 11
protected boolean lineStart (TextView widget, 
                Spannable buffer)

Performs a line-start movement action. Moves the cursor or scrolls to the start of the line.

Parameters
widget TextView: The text view.

buffer Spannable: The text buffer.

Returns
boolean True if the event was handled.

pageDown

Added in API level 11
protected boolean pageDown (TextView widget, 
                Spannable buffer)

Performs a page-down movement action. Moves the cursor or scrolls down by one page.

Parameters
widget TextView: The text view.

buffer Spannable: The text buffer.

Returns
boolean True if the event was handled.

pageUp

Added in API level 11
protected boolean pageUp (TextView widget, 
                Spannable buffer)

Performs a page-up movement action. Moves the cursor or scrolls up by one page.

Parameters
widget TextView: The text view.

buffer Spannable: The text buffer.

Returns
boolean True if the event was handled.

right

Added in API level 11
protected boolean right (TextView widget, 
                Spannable buffer)

Performs a right movement action. Moves the cursor or scrolls right by one character.

Parameters
widget TextView: The text view.

buffer Spannable: The text buffer.

Returns
boolean True if the event was handled.

top

Added in API level 11
protected boolean top (TextView widget, 
                Spannable buffer)

Performs a top movement action. Moves the cursor or scrolls to the top of the buffer.

Parameters
widget TextView: The text view.

buffer Spannable: The text buffer.

Returns
boolean True if the event was handled.

up

Added in API level 11
protected boolean up (TextView widget, 
                Spannable buffer)

Performs an up movement action. Moves the cursor or scrolls up by one line.

Parameters
widget TextView: The text view.

buffer Spannable: The text buffer.

Returns
boolean True if the event was handled.