TextView setMovementMethod - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for TextView setMovementMethod method.

This code example shows how to use the following methods:getLinksClickable, getText, setMovementMethod, setText
    private ListViewTool() { 
    } 
 
 
    public static void addLinks(TextView view) {
        CharSequence content = view.getText();
        view.setText(convertNormalStringToSpannableString(content.toString()));
        if (view.getLinksClickable()) {
            view.setMovementMethod(LongClickableLinkMovementMethod.getInstance());
        } 
    } 
 
    private static SpannableString convertNormalStringToSpannableString(String txt) {
        //hack to fix android imagespan bug,see http://stackoverflow.com/questions/3253148/imagespan-is-cut-off-incorrectly-aligned 
        //if string only contains emotion tags,add a empty char to the end 
        String hackTxt;
        if (txt.startsWith("[") && txt.endsWith("]")) {
            hackTxt = txt + " ";
        } else { 
            hackTxt = txt;
8
CodeRank
This code example shows how to use the following methods:setLinkTextColor, setMovementMethod, setPadding, setText, setTextColor
	public void onCreate(Bundle bundle) {
		super.onCreate(bundle);
		 
		setTitle("Information");
		 
		TextView tv = new TextView(this);
		tv.setTextColor(0xffffffff);
		tv.setLinkTextColor(0xffa3b8fe);
		int p = AndroidUtils.dipToPixel(this, 10);
		tv.setPadding(p, p, p, p);
		tv.setText(Html.fromHtml(getIntent().getStringExtra("info")));
		tv.setMovementMethod(LinkMovementMethod.getInstance());
		 
		ScrollView sv = new ScrollView(this);
		sv.addView(tv);
		 
		setContentView(sv);
	} 
} 
8
CodeRank
This code example shows how to use the following methods:getMovementMethod, getText, setMovementMethod, setText
		void onClick(); 
	} 
 
	public static void clickify(TextView view, final String clickableText, final MyClickableSpan.OnClickListener listener) {
 
		CharSequence text = view.getText();
		String string = text.toString();
		MyClickableSpan span = new MyClickableSpan(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);

7
CodeRank
This code example shows how to use the following methods:setMovementMethod, setText
public class Hyperlink implements StepView { 
 
    private TextView tvHyperlink;
 
    public Hyperlink(org.openecard.gui.definition.Hyperlink link, Context ctx) {
	tvHyperlink = new TextView(ctx);
	tvHyperlink.setText(Html.fromHtml("<a href=\"" + link.getHref() + "\">"
		+ ((link.getText() != null) ? link.getText() : link.getHref()) + "</a>"));
	tvHyperlink.setMovementMethod(LinkMovementMethod.getInstance());
    } 
 
    @Override 
    public View getView() {
	return tvHyperlink;
    } 
 
    @Override 
    public boolean validate() { 
	return true; 
    } 
7
CodeRank
This code example shows how to use the following methods:setMovementMethod, setText
        mHNView.setTypeface(tf);
         
        mURLView.setMovementMethod(LinkMovementMethod.getInstance());
        mURLView.setText(Html.fromHtml("<a href=\"mailto:me@manuelmaly.com\">me@manuelmaly.com</a>"));
         
        mGithubView.setMovementMethod(LinkMovementMethod.getInstance());
        mGithubView.setText(Html.fromHtml("<a href=\"https://github.com/manmal/hn-android/\">Get the Sourcecode</a>"));
    } 
 
    @Click(R.id.actionbar_back) 
    void backClicked() { 
        finish();
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:setMovementMethod, setText
        if (TextUtils.isEmpty(text)) {
            view.setText("");
            return; 
        } 
        if (text.contains("<") && text.contains(">")) {
            view.setText(Html.fromHtml(text));
            view.setMovementMethod(LinkMovementMethod.getInstance());
        } else { 
            view.setText(text);
        } 
    } 
 
 
    /** 
     * Given a snippet string with matching segments surrounded by curly 
     * braces, turn those areas into bold spans, removing the curly braces. 
     */ 
    public static Spannable buildStyledSnippet(String snippet) {
        final SpannableStringBuilder builder = new SpannableStringBuilder(snippet);
 
6
CodeRank
This code example shows how to use the following methods:setMovementMethod, setText
     * through {@link Html#fromHtml(String)} when applicable. Also sets 
     * {@link TextView#setMovementMethod} so inline links are handled. 
     */ 
    public static void setTextMaybeHtml(TextView view, String text) {
        if (text.contains("<") && text.contains(">")) {
            view.setText(Html.fromHtml(text));
            view.setMovementMethod(LinkMovementMethod.getInstance());
        } else { 
            view.setText(text);
        } 
    } 
 
    public static void setSessionTitleColor(long blockStart, long blockEnd, TextView title,
            TextView subtitle) {
        long currentTimeMillis = System.currentTimeMillis();
        int colorId = android.R.color.primary_text_light;
        int subColorId = android.R.color.secondary_text_light;
 
        if (currentTimeMillis > blockEnd &&
                currentTimeMillis < CONFERENCE_END_MILLIS) {
6
CodeRank
This code example shows how to use the following methods:setMovementMethod
			// on older Android version onFinishInflate can be called multiple times if the view contains includes 
			return; 
		} 
 
		MovementMethod mMethod = LinkMovementMethod.getInstance();
		mText.setMovementMethod(mMethod);
	} 
 
 
	@Override 
	public void setFieldDescription(FieldDescriptor descriptor, LayoutOptions layoutOptions)
	{ 
		super.setFieldDescription(descriptor, layoutOptions);
		mAdapter = (FieldAdapter<?>) descriptor.getFieldAdapter();
		mText.setHint(descriptor.getHint());
	} 
 
 
	@Override 
	public void onContentChanged(ContentSet contentSet)
5
CodeRank
This code example shows how to use the following methods:setMovementMethod
    private final static String LOG_TAG = "goodnews.DialogFactory";
 
    public static AlertDialog enableDialogClickLinks(AlertDialog dlg) {
        final TextView textView = (TextView) dlg.findViewById(android.R.id.message);
        if (textView != null) {
            textView.setMovementMethod(LinkMovementMethod.getInstance());
        } 
        return dlg;
    } 
 
    public static SpannableString getLinkifiedText(Context context, int textId) {
        return getLinkifiedText(context.getText(textId));
    } 
 
    public static SpannableString getLinkifiedText(CharSequence text) {
        final SpannableString msg = new SpannableString(text);
        Linkify.addLinks(msg, Linkify.ALL);
        return msg;
    } 
 
5
CodeRank
This code example shows how to use the following methods:setMovementMethod
            holder.pageImageView.setImageBitmap(bm);
            holder.pageImageView.setBackgroundDrawable(null);
            holder.progressBar.setVisibility(View.INVISIBLE);
            holder.descriptionView.setText(incidents.get(positionInArray).getDescription());
            holder.descriptionView.setVisibility(View.VISIBLE);
    		holder.descriptionView.setMovementMethod(new ScrollingMovementMethod());
        } 
 
    } 
 
    /** 
     * Scrolls the view very fast in the appropriate direction simulating a 
     * fling 
     */ 
    @Override 
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
            float velocityY) {
        float velMax = 1800f;
        float velMin = 800f;
        float velX = Math.abs(velocityX);
5
CodeRank

Related TextView setMovementMethod Questions & Answers:

setMovementMethod Method Overview
Sets the movement method (arrow key handler) to be used for this TextView.
See Code Examples for other Android TextView Methods: