【发布时间】:2022-01-08 12:18:32
【问题描述】:
我有一个 String 对象,其中包含我试图在 Textview 中单击的超链接,这是一个示例:
String descrption = "\"Cardano is a decentralised platform" +
" that will allow complex programmable transfers of" +
" value in a secure and scalable fashion. It is one" +
" of the first blockchains to be built in the highly" +
" secure Haskell programming language. Cardano is developing" +
" a <a href=\\\"https://www.coingecko.com/en?category_id=29\\\">smart contract platform</a>" +
" which seeks to deliver more advanced features than any protocol previously developed." +
" It is the first blockchain platform to evolve out of a scientific philosophy and a research-first driven approach." +
" The development team consists of a large global collective of expert engineers and researchers.\\r\\n\\r\\n" +
"The Cardano project is different from other blockchain projects as it openly addresses the need for regulatory oversight whilst maintaining" +
" consumer privacy and protections through an innovative software architecture.";
TextView textView = findViewById(R.id.description_textview);
Linkify.addLinks(textView, Linkify.WEB_URLS);
但结果是这样的:
如何让超链接的格式正确?
【问题讨论】:
-
这行得通,但它删除了所有换行符和回车符,所以我只得到一个长的连续文本。
标签: android hyperlink textview