ArrowKeyMovementMethod
public
class
ArrowKeyMovementMethod
extends BaseMovementMethod
implements
MovementMethod
A movement method that provides cursor movement and selection.
Supports displaying the context menu on DPad Center.
Summary
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.
|
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 |
From class
android.text.method.BaseMovementMethod
boolean
|
bottom(TextView widget, Spannable buffer)
Performs a bottom movement action.
|
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.
|
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.
|
void
|
initialize(TextView widget, Spannable text)
|
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
|
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
|
pageDown(TextView widget, Spannable buffer)
Performs a page-down movement action.
|
boolean
|
pageUp(TextView widget, Spannable buffer)
Performs a page-up movement action.
|
boolean
|
previousParagraph(TextView widget, Spannable buffer)
Performs a previous paragraph 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.
|
|
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait(long timeoutMillis, int nanos)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait(long timeoutMillis)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait()
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted.
|
|
From interface
android.text.method.MovementMethod
abstract
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.
|
abstract
void
|
initialize(TextView widget, Spannable text)
|
abstract
boolean
|
onGenericMotionEvent(TextView widget, Spannable text, MotionEvent event)
|
abstract
boolean
|
onKeyDown(TextView widget, Spannable text, int keyCode, KeyEvent event)
|
abstract
boolean
|
onKeyOther(TextView view, 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.
|
abstract
boolean
|
onKeyUp(TextView widget, Spannable text, int keyCode, KeyEvent event)
|
abstract
void
|
onTakeFocus(TextView widget, Spannable text, int direction)
|
abstract
boolean
|
onTouchEvent(TextView widget, Spannable text, MotionEvent event)
|
abstract
boolean
|
onTrackballEvent(TextView widget, Spannable text, MotionEvent event)
|
|
Public constructors
ArrowKeyMovementMethod
public ArrowKeyMovementMethod ()
Public methods
canSelectArbitrarily
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.
initialize
public void initialize (TextView widget,
Spannable text)
Parameters |
widget |
TextView |
text |
Spannable |
nextParagraph
public boolean nextParagraph (TextView widget,
Spannable buffer)
Performs a next paragraph movement action.
Parameters |
widget |
TextView : This value cannot be null . |
buffer |
Spannable : This value cannot be null . |
Returns |
boolean |
true if the event was handled, otherwise false. |
onTakeFocus
public void onTakeFocus (TextView view,
Spannable text,
int dir)
Parameters |
view |
TextView |
text |
Spannable |
dir |
int |
onTouchEvent
public boolean onTouchEvent (TextView widget,
Spannable buffer,
MotionEvent event)
Parameters |
widget |
TextView |
buffer |
Spannable |
event |
MotionEvent |
previousParagraph
public boolean previousParagraph (TextView widget,
Spannable buffer)
Performs a previous paragraph movement action.
Parameters |
widget |
TextView : This value cannot be null . |
buffer |
Spannable : This value cannot be null . |
Returns |
boolean |
true if the event was handled, otherwise false. |
Protected methods
bottom
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
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
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. |
handleMovementKey
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
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
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
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
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
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
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
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
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
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. |