문제

I know how to give a hyper link to word, but now i need to give hyperlink to a word within a paragraph ?

For example my paragraph:

Lorem Ipsum is simply dummy text of the printing and "typesetting industry". Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

Here i want to add hyper link to "typesetting industry" this word , is that possible?? if so please help me to get the solution.

도움이 되었습니까?

해결책

I could do this using below code,

TextView textView = (TextView)findViewById(R.id.text);
        textView.setText("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.");

        MatchFilter mMatchFilter = new MatchFilter() {
            public final boolean acceptMatch(CharSequence s, int start, int end) {
                return true;
            }
        };
        TransformFilter mTransformFilter = new TransformFilter() {
            public final String transformUrl(final Matcher match, String url) {
                return "www.google.com";
            }
        };

        Pattern mPattern = Pattern.compile("typesetting industry");
        String scheme = "http://";
        Linkify.addLinks(textView, mPattern, scheme, mMatchFilter, mTransformFilter);

다른 팁

Dear Brindha use this for a particular text,you can set web or email or phone or map or all as per your requirement.

android:autoLink="web|email|phone|map|all"

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top