Android链接地址而不显示完整地址

标签 android android-layout

所以我正在为用户真正不需要查看完整地址的特定区域编写应用程序。我想将 TextView 转换为 map 地址链接,但不想显式键入完整地址。

很简单,我只想显示地址号码和街道名称,但不显示城市、州和 zip 。有谁知道我该怎么做?这是我的一段代码。

textView.setText(towedVehicle.getAddress());
Linkify.addLinks(textView, Linkify.MAP_ADDRESSES);

最佳答案

经过一番搜索,我很容易解决了这个问题

Intent searchAddress = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=address+of+location")); 
startActivity(searchAddress); 

我使 textview 可点击并在其下划线使其看起来像一个普通链接。

SpannableString towedToAddress = new SpannableString(towedVehicle.getTowedToAddress());
            towedToAddress.setSpan(new UnderlineSpan(), 0,towedToAddress.length(), 0);
            towedToAddress.setSpan(new ForegroundColorSpan(0x990000FF), 0, towedToAddress.length(), 0);
            textView.setText(towedToAddress);
            textView.setClickable(true);

在 Google map 中打开并且效果很好。

关于Android链接地址而不显示完整地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5073630/

相关文章:

Android的盒子模型

android - 如何禁用布局的所有点击事件?

Android ADT Eclipse (Juno) 如何应用Dark UI Theme?

android - Visual Studio 2015 Cordova 插件添加失败

android - 为我自己的用户名指定的 Twitter JSON 搜索

android - 让 slider /线性布局的未显示部分不调整大小

android - 如何更改 ExpandableListView 组指示器位置?

java - Libgdx,按钮 onclick 事件崩溃

Android 将对象转换为 XML,反之亦然

Android水平布局,右侧动态扩展TextView