1

I have a listView, and ech item of listView has textView. I have set android:autoLink="web|email" to textView and onTouch listener across each item of listView.When I touch the textView, onTouch is not called.

What I want is that when link is present in a textView, only that link must be clickable.The rest of textView i want to get in that onTouch.And if link not present ,I want to get onTouch across entire entire listView item. Is there any way?..Pls help.

ShineDown
  • 1,881
  • 3
  • 21
  • 29

1 Answers1

1
String styledText = getResources().getString(R.string.Email);
    SpannableString span = new SpannableString(styledText);

    span.setSpan(new StyleSpan(Typeface.ITALIC),
            styledText.indexOf("Terms"), styledText.length(), 0);
    span.setSpan(new UnderlineSpan(), styledText.indexOf("Terms"),
            styledText.length(), 0);

    ClickableSpan clickSpan = new ClickableSpan() {

        @Override
        public void onClick(View widget) {
            // TODO Auto-generated method stub
            showInfoDialog();
        }
    };
    span.setSpan(clickSpan, styledText.indexOf("Terms"),
            styledText.length(), 0);
    span.setSpan(
            new ForegroundColorSpan(getResources().getColor(R.color.link_)),
            styledText.indexOf("Terms"), styledText.length(), 0);
    txt_accept.setText(span, BufferType.SPANNABLE);

Use this code as a reference and use ur logic..can't explain you the whole process..Comment if you need any help.

Hardik4560
  • 3,202
  • 1
  • 20
  • 31