【问题标题】:Textview multiple link in webview android?webview android中的Textview多个链接?
【发布时间】:2014-12-11 13:32:40
【问题描述】:

我是 android 开发新手.. 我只有一个这样的文本视图

 <TextView
        android:id="@+id/txt"
        android:layout_width="wrap_content"
        android:autoLink="web"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

然后我为 textview 设置 settext 像

<string name="content_ontheroad">Check road conditions on your route before you leave.\nEach state or territory has a different phone number and\nwebsite detailing relevant information, or ask a local.\n\n 

\u2022&#160;&#160;&#160;ACT  13 22 81\n          
 <a href="http://www.tams.act.gov.au/roads-transport">&#160;&#160;&#160;&#160;http://www.tams.act.gov.au/roads-transport</a> \n\n
\u2022&#160;&#160;&#160;N SW 13 27 01\n 
 <a href="https://www.livetraffic.com">&#160;&#160;&#160;&#160;https://www.livetraffic.com</a> \n\n
\u2022&#160;&#160;&#160;Northern Territory 1800 246 199 or\n  <a href="http://www.securent.nt.gov.au/">&#160;&#160;&#160;&#160;http://www.securent.nt.gov.au/</a>\n\n 
\u2022&#160;&#160;&#160;Queensland 13 19 40 or\n   <a href="http://www.racq.com.au/roadconditions">&#160;&#160;&#160;&#160;http://www.racq.com.au/roadconditions</a>\n\n   
\u2022&#160;&#160;&#160;South Australia 1300 361 033 or\n 
 <a href="http://www.dpti.sa.gov.au/OutbackRoads">&#160;&#160;&#160;&#160;http://www.dpti.sa.gov.au/OutbackRoads</a>\n\n 
\u2022&#160;&#160;&#160;Tasmania 1300 135 513 or\n  <a href="http://www.dier.tas.gov.au/road_closures_and_delays">&#160;&#160;&#160;&#160;http://www.dier.tas.gov.au/road_closures_and_delays</a>\n\n  
\u2022&#160;&#160;&#160;Victoria, 13 11 70 or\n  <a href="http://www.vicroads.vic.gov.au">&#160;&#160;&#160;&#160;http://www.vicroads.vic.gov.au</a>\n\n 
\u2022&#160;&#160;&#160;Western Australia 1800 013 314 or\n<a href="https://www.mainroads.wa.gov.au/UsingRoads/RoadTrafficInformation/Pages/RoadTrafficInformation.aspx">&#160;&#160;&#160;&#160;https://www.mainroads.wa.gov.au/UsingRoads/RoadTrafficInformation/Pages/RoadTrafficInformation.aspx</a> \n\n

On country roads, always keep alert for wildlife, particularly\n at dawn or dusk when animals may be active. Be cautious,\n scanning both the road ahead and the roadsides.  Be\n aware of traffic behind you, as well as oncoming traffic.\n\n 
When safe to do so, use your high beam headlights so that\n you can see further when driving at night. However, bright\n lights can dazzle animals and rather than move off the\n road, they may remain stationery and in the path of your\n vehicle.\n\n
When travelling at speed, do not swerve to avoid hitting an\n animal, as this could put you and other motorists in danger.\n Sometimes, it may be impossible to avoid a collision with\n an animal.\n\n
More information:\n\n<a href="http://www.racv.com.au/wps/wcm/connect/racv/Internet/Primary/travel/before+you+go/driving+tips">http://www.racv.com.au/wps/wcm/connect/racv/Internet/Primary/travel/before+you+go/driving+tips</a></string>

它有不止一个链接。我启用自动链接到 textview 以在默认浏览器中打开链接。 但我需要在我的应用程序中的 webview 中打开它

【问题讨论】:

标签: android webview


【解决方案1】:

假设您想将每个 href 设置为新的 Web 视图... 首先,为文本的每个部分设置不同的文本视图。然后哪个部分有href,只需设置下划线和颜色蓝色或任何东西。另外,您可以单独添加其他属性。 现在,对于每个 textview,给它 setOnClick 事件并将它们重定向到您的 webview 意图。

希望有帮助:)

【讨论】:

    猜你喜欢
    • 2020-09-13
    • 2012-12-26
    • 2015-04-27
    • 1970-01-01
    • 2011-06-29
    • 1970-01-01
    • 1970-01-01
    • 2016-12-13
    • 1970-01-01
    相关资源
    最近更新 更多