我正在使用TextView的android:autoLink="map"
属性来进入地图并查找与该textview相关联的地址。
但是它的行为很奇怪,只能找到一些地址。这是我正在尝试的代码:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textViewautoLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/autolinktext"
android:autoLink="map"></TextView>
</LinearLayout>
这是我的strings.xml文件。
strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="autolinktext">1600 Amphitheatre Parkway, Mountain View, CA 94043 </string>
</resources>
问题是:
假设我写上面的字符串,即1600 Amphitheatre Parkway, Mountain View, CA 94043,那么它工作得很好,textView变成蓝色,当我点击它时,它会在地图上搜索地址。
当我将此地址更改为:1600 Amphitheatre Parkway, Mumbai, IN,它仍然显示相同的内容,并尝试搜索地址,但由于地址错误,无法找到。这没关系。
但是当我写其他地址时,例如:600 Band Stand, Mumbai, IN,则:
1)textview不是蓝色 2)它似乎不能点击 3)由于它不能点击,所以找不到地址。
我正在搜索谷歌,但没有找到任何原因来解释这种行为。 我还想知道:
是否有编写此地图地址的格式? 另外,Android如何通过只在字符串中编写地址(我已经按相同的格式编写了相同的地址,只是更改了字符串),就知道地址是否有效?
请帮忙。