Yaya
Yaya

Reputation: 620

android disable onclick event when url links clicked

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 .

Upvotes: 6

Views: 3698

Answers (2)

Orkun
Orkun

Reputation: 7248

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);

Upvotes: 12

techi.services
techi.services

Reputation: 8533

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

Upvotes: 0

Related Questions