所以我正在为特定区域编写应用程序,用户实际上不需要查看完整地址。我想将textview转换为地图地址链接,但不想显式输入完整地址。
非常简单,我只想显示地址编号和街道名称,但保留城市,州和拉链。有谁知道我怎么做到这一点?这是我的一大块代码。
textView.setText(towedVehicle.getAddress());
Linkify.addLinks(textView, Linkify.MAP_ADDRESSES);
答案 0 :(得分:1)
经过一番搜索后,我能够很轻松地解决它
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地图中打开,效果很好。
答案 1 :(得分:0)
您应该可以使用Transformfilters
方法中的addLinks
执行此操作。有关示例,请查看此link。