Most visited

Recently visited

Added in API level 11

BaseMovementMethod

public class BaseMovementMethod
extends Object implements MovementMethod

java.lang.Object
   ↳ android.text.method.BaseMovementMethod
Known Direct Subclasses
Known Indirect Subclasses


移动方法的基类。

Summary

Public constructors

BaseMovementMethod()

Public methods

boolean canSelectArbitrarily()

如果此移动方法允许任意选择任何文本,则返回true; 如果它没有选择(如仅滚动的移动方法)或受限选择(例如限于链接),则为false。

void initialize(TextView widget, Spannable text)
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)

如果键监听器想要其他类型的键事件,则返回true,否则返回false并且调用者(即

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)

Protected methods

boolean bottom(TextView widget, Spannable buffer)

执行底部移动动作。

boolean down(TextView widget, Spannable buffer)

执行向下移动动作。

boolean end(TextView widget, Spannable buffer)

执行结束移动操作。

int getMovementMetaState(Spannable buffer, KeyEvent event)

获取用于移动的元状态,使用文本缓冲区跟踪的修饰符以及键事件中存在的修饰符。

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

执行移动关键动作。

boolean home(TextView widget, Spannable buffer)

执行家庭活动行动。

boolean left(TextView widget, Spannable buffer)

执行左移动作。

boolean lineEnd(TextView widget, Spannable buffer)

执行线端移动操作。

boolean lineStart(TextView widget, Spannable buffer)

执行行开始移动操作。

boolean pageDown(TextView widget, Spannable buffer)

执行向下翻页动作。

boolean pageUp(TextView widget, Spannable buffer)

执行翻页移动操作。

boolean right(TextView widget, Spannable buffer)

执行正确的移动操作。

boolean top(TextView widget, Spannable buffer)

执行顶级移动操作。

boolean up(TextView widget, Spannable buffer)

执行上移动作。

Inherited methods

From class java.lang.Object
From interface android.text.method.MovementMethod

Public constructors

BaseMovementMethod

Added in API level 11
BaseMovementMethod ()

Public methods

canSelectArbitrarily

Added in API level 1
boolean canSelectArbitrarily ()

如果此移动方法允许任意选择任何文本,则返回true; 如果它没有选择(如只有滚动的移动方法)或受限选择(例如限于链接),则为false。如果不允许任意选择,则“全选”菜单项将被禁用。

Returns
boolean

initialize

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

Parameters
widget TextView
text Spannable

onGenericMotionEvent

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

Parameters
widget TextView
text Spannable
event MotionEvent
Returns
boolean

onKeyDown

Added in API level 1
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 3
boolean onKeyOther (TextView widget, 
                Spannable text, 
                KeyEvent event)

如果键监听器想要其他类型的键事件,则返回true,否则返回false,并且调用方(即小部件主机)将处理该键。

Parameters
widget TextView
text Spannable
event KeyEvent
Returns
boolean

onKeyUp

Added in API level 1
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
void onTakeFocus (TextView widget, 
                Spannable text, 
                int direction)

Parameters
widget TextView
text Spannable
direction int

onTouchEvent

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

Parameters
widget TextView
text Spannable
event MotionEvent
Returns
boolean

onTrackballEvent

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

Parameters
widget TextView
text Spannable
event MotionEvent
Returns
boolean

Protected methods

bottom

Added in API level 11
boolean bottom (TextView widget, 
                Spannable 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
boolean down (TextView widget, 
                Spannable buffer)

执行向下移动动作。 移动光标或向下滚动一行。

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
boolean end (TextView widget, 
                Spannable buffer)

执行结束移动操作。 根据插入点正在移动还是正在滚动文档,将光标或滚动移动到行的开头或文档的顶部。

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
int getMovementMetaState (Spannable buffer, 
                KeyEvent event)

获取用于移动的元状态,使用文本缓冲区跟踪的修饰符以及键事件中存在的修饰符。 移动元状态排除锁定修饰符或SHIFT键的状态,因为它们不被移动动作使用(但可用于选择)。

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
boolean handleMovementKey (TextView widget, 
                Spannable buffer, 
                int keyCode, 
                int movementMetaState, 
                KeyEvent event)

执行移动关键动作。 默认实现将密钥解码并调用移动操作,如down(TextView, Spannable)up(TextView, Spannable) onKeyDown(TextView, Spannable, int, KeyEvent)调用此方法一次来处理ACTION_DOWN onKeyOther(TextView, Spannable, 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
boolean home (TextView widget, 
                Spannable buffer)

执行家庭活动行动。 根据插入点正在移动还是正在滚动文档,将光标或滚动移动到行的开头或文档的顶部。

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
boolean left (TextView widget, 
                Spannable buffer)

执行左移动作。 移动光标或向左滚动一个字符。

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
boolean lineEnd (TextView widget, 
                Spannable buffer)

执行线端移动操作。 将光标或滚动移动到行的末尾。

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
boolean lineStart (TextView widget, 
                Spannable buffer)

执行行开始移动操作。 将光标或滚动移动到行的开头。

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
boolean pageDown (TextView widget, 
                Spannable buffer)

执行向下翻页动作。 移动光标或向下滚动一页。

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
boolean pageUp (TextView widget, 
                Spannable buffer)

执行翻页移动操作。 移动光标或向上滚动一页。

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
boolean right (TextView widget, 
                Spannable buffer)

执行正确的移动操作。 移动光标或向右滚动一个字符。

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
boolean top (TextView widget, 
                Spannable 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
boolean up (TextView widget, 
                Spannable buffer)

执行上移动作。 移动光标或向上滚动一行。

Parameters
widget TextView: The text view.
buffer Spannable: The text buffer.
Returns
boolean True if the event was handled.

Hooray!