本文整理汇总了Java中android.text.method.ArrowKeyMovementMethod类的典型用法代码示例。如果您正苦于以下问题:Java ArrowKeyMovementMethod类的具体用法?Java ArrowKeyMovementMethod怎么用?Java ArrowKeyMovementMethod使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ArrowKeyMovementMethod类属于android.text.method包,在下文中一共展示了ArrowKeyMovementMethod类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onFinishInflate
import android.text.method.ArrowKeyMovementMethod; //导入依赖的package包/类
protected void onFinishInflate()
{
super.onFinishInflate();
this.mDetailsExpandedCallout = ((TextView)findViewById(2131755581));
this.mDetailsExpandedCallout.setMovementMethod(LinkMovementMethod.getInstance());
this.mDetailsExpandedBody1 = ((DetailsTextBlock)findViewById(2131755582));
this.mDetailsExpandedBody2 = ((DetailsTextBlock)findViewById(2131755583));
this.mDetailsExpandedExtras = ((ViewGroup)findViewById(2131755584));
if (Build.VERSION.SDK_INT >= 11)
{
this.mDetailsExpandedCallout.setTextIsSelectable(true);
this.mDetailsExpandedCallout.setAutoLinkMask(15);
this.mDetailsExpandedCallout.setMovementMethod(ArrowKeyMovementMethod.getInstance());
}
this.mDetailsExpandedBody1.setBodyTextIsSelectable(true);
this.mDetailsExpandedBody2.setBodyTextIsSelectable(true);
}
示例2: checkMentionSpannable
import android.text.method.ArrowKeyMovementMethod; //导入依赖的package包/类
/**
* 为TextView设置显示@效果
*/
public static void checkMentionSpannable(TextView textView, String content, List<String> allMention) {
if (textView == null) {
return;
}
if (allMention.isEmpty() || TextUtils.isEmpty(content)) {
textView.setText(content);
textView.setMovementMethod(ArrowKeyMovementMethod.getInstance());
return;
}
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(content);
int lastMentionIndex = -1;
for (String mention : allMention) {
Matcher matcher = Pattern.compile("\\[email protected]" + mention + "\\E").matcher(content);
while (matcher.find()) {
String mentionText = matcher.group();
int start;
if (lastMentionIndex != -1) {
start = content.indexOf(mentionText, lastMentionIndex);
} else {
start = content.indexOf(mentionText);
}
int end = start + mentionText.length();
spannableStringBuilder.setSpan(new MentionSpan(mentionText), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
textView.setText(spannableStringBuilder);
textView.setMovementMethod(LinkMovementMethod.getInstance());
}
示例3: setEditable
import android.text.method.ArrowKeyMovementMethod; //导入依赖的package包/类
public void setEditable(boolean editable, @Nullable CharSequence hint) {
if (mEditable == editable) {
return;
}
mEditable = editable;
setFocusable(editable);
setFocusableInTouchMode(editable);
setHint(hint);
setMovementMethod(editable ? ArrowKeyMovementMethod.getInstance() : null);
resetPaint();
}
示例4: setBodyTextIsSelectable
import android.text.method.ArrowKeyMovementMethod; //导入依赖的package包/类
public void setBodyTextIsSelectable(boolean paramBoolean)
{
if (Build.VERSION.SDK_INT >= 11)
{
this.mBodyView.setTextIsSelectable(paramBoolean);
this.mBodyView.setAutoLinkMask(15);
this.mBodyView.setMovementMethod(ArrowKeyMovementMethod.getInstance());
}
}
示例5: testMovementMethod
import android.text.method.ArrowKeyMovementMethod; //导入依赖的package包/类
@Test
public void testMovementMethod() {
MovementMethod movement = new ArrowKeyMovementMethod();
assertNull(textView.getMovementMethod());
textView.setMovementMethod(movement);
assertThat(textView.getMovementMethod()).isSameAs(movement);
}
示例6: onCreateView
import android.text.method.ArrowKeyMovementMethod; //导入依赖的package包/类
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Logger.debug("PostFragment CreateView");
MainActivity activity = (MainActivity) getActivity();
PostState.getState().setListener(this);
UserPreferenceHelper preferenceHelper = new UserPreferenceHelper(activity);
View v = inflater.inflate(R.layout.fragment_post, null);
buttonTweet = getTweetButton(v);
buttonTweet.setOnClickListener(this);
editText = getEditText(v);
textViewCount = getCountTextView(v);
int textSize = preferenceHelper.getValue(R.string.key_setting_text_size, 10);
editText.addTextChangedListener(this);
editText.setOnFocusChangeListener(this);
editText.setTextSize(textSize + 4);
editText.setMovementMethod(new ArrowKeyMovementMethod() {
@Override
protected boolean right(TextView widget, Spannable buffer) {
//Don't back to Home
return widget.getSelectionEnd() == widget.length() || super.right(widget, buffer);
}
});
ImageButton imageButtonDeleteText = (ImageButton) v.findViewById(R.id.button_post_delete);
imageButtonDeleteText.setOnClickListener(this);
ImageButton imageButtonMedia = (ImageButton) v.findViewById(R.id.button_post_media);
imageButtonMedia.setOnClickListener(this);
ImageButton imageButtonMenu = (ImageButton) v.findViewById(R.id.button_post_menu);
imageButtonMenu.setOnClickListener(this);
//Reply view
viewGroupReply = getReplyViewGroup(v);
ImageButton imageButtonDeleteReply = (ImageButton) viewGroupReply.findViewById(R.id.button_post_reply_delete);
imageButtonDeleteReply.setOnClickListener(this);
//Media view
viewGroupMedia = getMediaViewGroup(v);
ImageView imageViewMedia = (ImageView) viewGroupMedia.findViewById(R.id.image_post_media);
ImageButton imageButtonDeleteMedia = (ImageButton) viewGroupMedia.findViewById(R.id.button_post_media_delete);
imageViewMedia.setOnClickListener(this);
imageButtonDeleteMedia.setOnClickListener(this);
editText.requestFocus();
return v;
}
示例7: getDefaultMovementMethod
import android.text.method.ArrowKeyMovementMethod; //导入依赖的package包/类
@Override
protected MovementMethod getDefaultMovementMethod() {
return ArrowKeyMovementMethod.getInstance();
}
示例8: setTextIsSelectable
import android.text.method.ArrowKeyMovementMethod; //导入依赖的package包/类
/**
* Sets whether the content of this view is selectable by the user. The default is
* {@code false}, meaning that the content is not selectable.
* <p>
* When you use a TextView to display a useful piece of information to the user (such as a
* contact's address), make it selectable, so that the user can select and copy its
* content. You can also use set the XML attribute
* {@link android.R.styleable#TextView_textIsSelectable} to "true".
* <p>
* When you call this method to set the value of {@code textIsSelectable}, it sets
* the flags {@code focusable}, {@code focusableInTouchMode}, {@code clickable},
* and {@code longClickable} to the same value. These flags correspond to the attributes
* {@link android.R.styleable#View_focusable android:focusable},
* {@link android.R.styleable#View_focusableInTouchMode android:focusableInTouchMode},
* {@link android.R.styleable#View_clickable android:clickable}, and
* {@link android.R.styleable#View_longClickable android:longClickable}. To restore any of these
* flags to a state you had set previously, call one or more of the following methods:
* {@link #setFocusable(boolean) setFocusable()},
* {@link #setFocusableInTouchMode(boolean) setFocusableInTouchMode()},
* {@link #setClickable(boolean) setClickable()} or
* {@link #setLongClickable(boolean) setLongClickable()}.
*
* @param selectable Whether the content of this TextView should be selectable.
*/
public void setTextIsSelectable(boolean selectable) {
if (!selectable && mEditor == null) return; // false is default value with no edit data
createEditorIfNeeded();
if (mEditor.mTextIsSelectable == selectable) return;
mEditor.mTextIsSelectable = selectable;
setFocusableInTouchMode(selectable);
setFocusable(selectable);
setClickable(selectable);
setLongClickable(selectable);
// mInputType should already be EditorInfo.TYPE_NULL and mInput should be null
setMovementMethod(selectable ? ArrowKeyMovementMethod.getInstance() : null);
setText(mText, selectable ? BufferType.SPANNABLE : BufferType.NORMAL);
// Called by setText above, but safer in case of future code changes
mEditor.prepareCursorControllers();
}
示例9: onResume
import android.text.method.ArrowKeyMovementMethod; //导入依赖的package包/类
@Override
protected void onResume()
{
super.onResume();
getNoteFromFile();
// Make sure that we don't use the link movement method.
// Instead, we need a blend between the arrow key movement (for regular
// navigation) and
// the link movement (so the user can click on links).
// TODO: Might be able to edit this, since we don't care about
// linkifying text
getMText().setMovementMethod(new ArrowKeyMovementMethod()
{
public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event)
{
// This block is copied and pasted from LinkMovementMethod's
// onTouchEvent (without the part that actually changes the
// selection).
int action = event.getAction();
if (action == MotionEvent.ACTION_UP)
{
int x = (int) event.getX();
int y = (int) event.getY();
x -= widget.getTotalPaddingLeft();
y -= widget.getTotalPaddingTop();
x += widget.getScrollX();
y += widget.getScrollY();
Layout layout = widget.getLayout();
int line = layout.getLineForVertical(y);
int off = layout.getOffsetForHorizontal(line, x);
ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class);
if (link.length != 0)
{
link[0].onClick(widget);
return true;
}
}
return super.onTouchEvent(widget, buffer, event);
}
});
}
示例10: onResume
import android.text.method.ArrowKeyMovementMethod; //导入依赖的package包/类
@Override
protected void onResume()
{
super.onResume();
getNoteFromFile();
// Make sure that we don't use the link movement method.
// Instead, we need a blend between the arrow key movement (for regular
// navigation) and
// the link movement (so the user can click on links).
// TODO: Might be able to edit this, since we don't care about
// linkifying text
mText.setMovementMethod(new ArrowKeyMovementMethod()
{
public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event)
{
// This block is copied and pasted from LinkMovementMethod's
// onTouchEvent (without the part that actually changes the
// selection).
int action = event.getAction();
if (action == MotionEvent.ACTION_UP)
{
int x = (int) event.getX();
int y = (int) event.getY();
x -= widget.getTotalPaddingLeft();
y -= widget.getTotalPaddingTop();
x += widget.getScrollX();
y += widget.getScrollY();
Layout layout = widget.getLayout();
int line = layout.getLineForVertical(y);
int off = layout.getOffsetForHorizontal(line, x);
ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class);
if (link.length != 0)
{
link[0].onClick(widget);
return true;
}
}
return super.onTouchEvent(widget, buffer, event);
}
});
}
示例11: getDefaultMovementMethod
import android.text.method.ArrowKeyMovementMethod; //导入依赖的package包/类
protected final MovementMethod getDefaultMovementMethod()
{
return ArrowKeyMovementMethod.getInstance();
}