当URL链接点击安卓禁用onclick事件 [英] android disable onclick event when url links clicked

查看:235
本文介绍了当URL链接点击安卓禁用onclick事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的TextView 包含网​​址喜欢的 www.google.com 的。此的TextView A还创建了一个onclicklistener。

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

我的问题是,当用户clickes www.google.com,的链接用于由活动,但还创建活动 的onclick 事件。但我不希望创建的onclick 事件时的URL用户点击。

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 .

是否有可能为texview禁用的onclick 活动时,像的 http://www.google.com ,市场://安卓..等等

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

编辑1:我在下面的详细信息。

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

的链接创建的TextView后,再放入另一个事件的onclick其他文本。

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

                    }
                }
            }));

现在,当用户点击URL链接,我不想其他onclick事件工作的链接。

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

推荐答案

哇。 Android是魔术。有一个单独的<一href=\"http://developer.android.com/reference/android/widget/TextView.html#setLinksClickable%28boolean%29\"相对=nofollow>属性为:

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

android:linksClickable:"false"

您可以改变它在code,通过:

You can change it in the code, via :

myTextView.setLinksClickable(false);

这篇关于当URL链接点击安卓禁用onclick事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆