所以我正在为用户真正不需要查看完整地址的特定区域编写应用程序。我想将 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/