apradanas / simple-linkable-text

Simple way to create linked text, such as @username or #hashtag, in Android TextView and EditText
Other
74 stars 13 forks source link

Set text to LinkableTextView not working #9

Open feresr opened 8 years ago

feresr commented 8 years ago

The snippet below will not update te text displayed on the TextView. It works fine using the LinkableEDITTEXT though

        tv = (LinkableTextView) findViewById(R.id.heloworld);

        Link linkHashtag = new Link(Pattern.compile("(#\\w+)"))
                .setUnderlined(true)
                .setTextStyle(Link.TextStyle.BOLD)
                .setUnderlined(false)
                .setTextColor(Color.DKGRAY);
        tv.addLink(linkHashtag);
        tv.setText("This does not get set at all");
farukprogrammer commented 8 years ago

you need to add .build() instead..

    tv.setText("This does not get set at all")
       .addLink(linkHashtag)
       .build();