6

I have textview which contains urls like www.google.com. for this textview a have also created a onclicklistener.

My problem is when user clickes www.google.com, link is used by an activity, but after that activity onclick event is also created. but i dont want to create onclick events when user clicks on urls .

Is it possible for texview to disable onclick events when user clickes on urls like http://www.google.com, market://android.. etc.

EDIT 1: I added details below.

            TextView entry = (TextView) v
                    .findViewById(R.id.textViewEntryText);
            entry.setText(Html.fromHtml(String.format("%s",
                    (CharSequence) displayText)));
            entry.setMovementMethod(LinkMovementMethod.getInstance());

after creating textview with links then put another events onclick other texts.

            entry.setOnClickListener((new View.OnClickListener() {

                // TODO Auto-generated method stub

                public void onClick(View v) {
                    // TODO Auto-generated method stub

                    }
                }
            }));

Now when user clicks on url link i dont want to other onclick event works for links .

Valery Viktorovsky
  • 6,487
  • 3
  • 39
  • 47
Yaya
  • 600
  • 1
  • 11
  • 28
  • I think you have to clarify your question a little further. Is what you want clickable textviews without the action as links? – Orkun Mar 02 '12 at 18:16
  • @techiServices's answer might be more accurate actually, have you tried that? – Orkun Mar 02 '12 at 18:17

2 Answers2

10

wow. Android is magic. There is a seperate attribute for that:

android:linksClickable:"false"

You can change it in the code, via :

myTextView.setLinksClickable(false);
Orkun
  • 6,998
  • 8
  • 56
  • 103
0

You can use android:autoLink in the XML or TextView.setAutoLinkMask(int) to control whether links are searched for.

techi.services
  • 8,473
  • 4
  • 39
  • 42