本文整理了Java中android.widget.TextView.getMovementMethod()
方法的一些代码示例,展示了TextView.getMovementMethod()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.getMovementMethod()
方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:getMovementMethod
暂无
代码示例来源:origin: stackoverflow.com
public static void clickify(TextView view, final String clickableText,
final ClickSpan.OnClickListener listener) {
CharSequence text = view.getText();
String string = text.toString();
ClickSpan span = new ClickSpan(listener);
int start = string.indexOf(clickableText);
int end = start + clickableText.length();
if (start == -1) return;
if (text instanceof Spannable) {
((Spannable)text).setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} else {
SpannableString s = SpannableString.valueOf(text);
s.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
view.setText(s);
}
MovementMethod m = view.getMovementMethod();
if ((m == null) || !(m instanceof LinkMovementMethod)) {
view.setMovementMethod(LinkMovementMethod.getInstance());
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testMovementMethod() {
MovementMethod movement = new ArrowKeyMovementMethod();
assertNull(textView.getMovementMethod());
textView.setMovementMethod(movement);
assertThat(textView.getMovementMethod()).isSameAs(movement);
}
代码示例来源:origin: stackoverflow.com
MovementMethod m = view.getMovementMethod();
if ((m == null) || !(m instanceof LinkMovementMethod)) {
view.setMovementMethod(LinkMovementMethod.getInstance());
代码示例来源:origin: stackoverflow.com
private static final void addLinkMovementMethod(TextView t) {
MovementMethod m = t.getMovementMethod();
if ((m == null) || !(m instanceof LocalLinkMovementMethod)) {
if (t.getLinksClickable()) {
t.setMovementMethod(LocalLinkMovementMethod.getInstance());
}
}
}
代码示例来源:origin: stackoverflow.com
private void addLinkMovementMethod(TextView t) {
MovementMethod m = t.getMovementMethod();
if ((m == null) || !(m instanceof LinkMovementMethod)) {
if (t.getLinksClickable()) {
t.setMovementMethod(LinkMovementMethod.getInstance());
}
}
}
代码示例来源:origin: stackoverflow.com
private void addLinks(TextView textView, Pattern pattern) {
SpannableString spannable = SpannableString.valueOf(textView.getText());
Matcher matcher = pattern.matcher(spannable);
// Create ActivitySpans for each match
while (matcher.find())
spannable.setSpan(new ActivitySpan(matcher.group()), matcher.start(), matcher.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
// Set new spans in TextView
textView.setText(spannable);
// Listen for spannable clicks, if not already
MovementMethod m = textView.getMovementMethod();
if ((m == null) || !(m instanceof LinkMovementMethod)) {
if (textView.getLinksClickable()) {
textView.setMovementMethod(LinkMovementMethod.getInstance());
}
}
}
代码示例来源:origin: stackoverflow.com
public static void clickify(TextView view, final String clickableText,
final ClickSpan.OnClickListener listener) {
CharSequence text = view.getText();
String string = text.toString();
ClickSpan span = new ClickSpan(listener);
int start = string.indexOf(clickableText);
int end = start + clickableText.length();
if (start == -1) return;
if (text instanceof Spannable) {
((Spannable)text).setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} else {
SpannableString s = SpannableString.valueOf(text);
s.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
view.setText(s);
}
MovementMethod m = view.getMovementMethod();
if ((m == null) || !(m instanceof LinkMovementMethod)) {
view.setMovementMethod(LinkMovementMethod.getInstance());
}
}
代码示例来源:origin: stackoverflow.com
public static void clickify(TextView view,
final ClickSpan.OnClickListener listener) {
CharSequence text = view.getText();
String string = text.toString();
ArrayList<String> linksInText = getLinksFromText(string);
if (linksInText.isEmpty()){
return;
}
String clickableText = linksInText.get(0);
ClickSpan span = new ClickSpan(listener,clickableText);
int start = string.indexOf(clickableText);
int end = start + clickableText.length();
if (start == -1) return;
if (text instanceof Spannable) {
((Spannable) text).setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} else {
SpannableString s = SpannableString.valueOf(text);
s.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
view.setText(s);
}
MovementMethod m = view.getMovementMethod();
if ((m == null) || !(m instanceof LinkMovementMethod)) {
view.setMovementMethod(LinkMovementMethod.getInstance());
}
}
代码示例来源:origin: stackoverflow.com
MovementMethod m = view.getMovementMethod();
if (m == null || !(m instanceof LinkTouchMovementMethod)) {
view.setMovementMethod(LinkTouchMovementMethod.getInstance());
代码示例来源:origin: animalize/QuanTangshi
private void setText(TextView view, final String str) {
ArrayList<Position> list = new ArrayList<>();
for (int i = 0; i < str.length(); i++) {
final int temp_i = i;
final char c = str.charAt(temp_i);
if (c == '\n') {
continue;
}
if (Character.isHighSurrogate(c) &&
temp_i + 1 < str.length() &&
Character.isLowSurrogate(str.charAt(temp_i + 1))) {
list.add(new Position(temp_i, temp_i + 2));
i += 1;
} else {
list.add(new Position(temp_i, temp_i + 1));
}
}
SpannableString ss = new SpannableString(str);
for (Position p : list) {
String s = str.substring(p.begin, p.end);
MyClickableSpan clickable = new MyClickableSpan(StudyActivity.this, s);
ss.setSpan(clickable, p.begin, p.end,
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}
if (view.getMovementMethod() == null) {
view.setMovementMethod(LinkMovementMethod.getInstance());
}
view.setText(ss, TextView.BufferType.SPANNABLE);
}
代码示例来源:origin: stackoverflow.com
if (textView.getMovementMethod()==null) {
textView.setMovementMethod(LinkMovementMethod.getInstance());
textView.setHighlightColor(Color.TRANSPARENT);
代码示例来源:origin: stackoverflow.com
MovementMethod m = link.getMovementMethod();
if ((m == null) || !(m instanceof LinkMovementMethod))
代码示例来源:origin: animalize/QuanTangshi
private void refreshPoem(boolean toTop) {
mTitle.setText(mPoemWrapper.getTitle(mChineseMode));
mId.setText("" + mPoemWrapper.getID());
mAuthor.setText(mPoemWrapper.getAuthor(mChineseMode));
if (mChineseMode == 0 || mChineseMode == 1) {
mText.setText(mPoemWrapper.getText(mChineseMode));
} else {
ArrayList<PoemWrapper.CodepointPosition> lst = mPoemWrapper.getCodeList();
SpannableString ss = new SpannableString(mPoemWrapper.getText(mChineseMode));
for (final PoemWrapper.CodepointPosition p : lst) {
MyClickableSpan clickable = new MyClickableSpan(
getContext(),
String.valueOf(Character.toChars(p.s_codepoint))
);
ss.setSpan(clickable,
p.begin, p.end,
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}
if (mText.getMovementMethod() == null) {
mText.setMovementMethod(LinkMovementMethod.getInstance());
}
mText.setText(ss, TextView.BufferType.SPANNABLE);
}
if (toTop) {
mScroller.scrollTo(0, 0);
}
}
代码示例来源:origin: stackoverflow.com
MovementMethod m = tv.getMovementMethod();
if ((m == null) || !(m instanceof LinkMovementMethod)) {
if (tv.getLinksClickable()) {
代码示例来源:origin: stackoverflow.com
MovementMethod m = textView.getMovementMethod();
if ((m == null) || !(m instanceof LinkMovementMethod)) {
if (textView.getLinksClickable()) {
代码示例来源:origin: jbruchanov/AnUitor
values.put("HintTextColor", getStringColor(tv.getCurrentHintTextColor()));
values.put("LinksClickable", tv.getLinksClickable());
values.put("MovementMethod", String.valueOf(tv.getMovementMethod()));
values.put("Gravity", translator.gravity(tv.getGravity()));
values.put("AutoLinkMask", translator.linkMask(tv.getAutoLinkMask()));
代码示例来源:origin: stackoverflow.com
MovementMethod m = tv.getMovementMethod();
if ((m == null) || !(m instanceof LinkMovementMethod)) {
if (tv.getLinksClickable()) {
内容来源于网络,如有侵权,请联系作者删除!