链接和文本列表视图项 [英] Links and text in listview item

查看:190
本文介绍了链接和文本列表视图项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想重新含在G + -app在我的Andr​​oid项目的用户的消息TextView的行为。准确地说:
- 在点击一个链接的链接选择视觉(蓝色选择器),将在浏览器中打开
- 在点击普通文本的选择了整个项目

I like to recreate the behaviour of the textview containing the message of a user in the g+-app in my android project. To be exact: - on click on a link the link is visually selected (blue selector) and will open up in the browser - on click on normal text the whole list item is selected

我也有,主要的问题是,每一个方法我试图使可点击的链接(通过XML和自动连接=网络或code)结束,该链接在点击浏览器中打开,但当我在TextView的项目没有选择触摸正常的文本(没有选择可见)。
我读到这个问题很多线程,但所有的解决方案,如增加setFocusable(假),等等。对我来说是行不通的。

The main problem I have, is, that every approach I tried to make links clickable (via xml and autolink=web, or in code) ends up, that the link opens up in a browser on click, but when I touch normal text in this textview the item is not selected (no selector is visible). I read many threads about this issue, but all the solutions, like add setFocusable(false), etc. doesn't work for me.

所以,我想问一下,如果有任何教程,如何或例子,在那里我可以看到这是如何工作的,或者你有什么想法,我怎么能得到它的工作?

So I want to ask, if there is any tutorial, how to or example, where I can see how this things work, or do you have any idea how I can get it to work?

谢谢! :)

推荐答案

如果你有以下code TextView中使用电子邮件ID ..

if you have email id in textview use below code..

TextView email = (TextView)findViewById(R.id.TextView04);
email.setText("sasd asd@gmai.com sadasd");
email.setLinkTextColor(Color.WHITE);
Linkify.addLinks(email,Linkify.EMAIL_ADDRESSES);

如果您在使用的TextView下面的网址code ...

if you have url in textview use below code...

TextView tv = (TextView)findViewById(R.id.TextView04);
tv.setText("sasd https://asd.com sadasd");
tv.setLinkTextColor(Color.WHITE);
Linkify.addLinks(tv,Linkify.WEB_URLS);

这篇关于链接和文本列表视图项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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