【发布时间】:2014-02-20 04:50:50
【问题描述】:
我在我的应用程序中使用自定义信息窗口。我有两个与之相关的问题。
- 是否可以在 InfoWindow 中制作多行 sn-p
假设我正在添加一些数据,假设我需要在单击标记时显示 LATTITUDE 和 LONGITUDE。通常,如果您在 sn-p 中设置这些值,它们会出现在同一行。我想在两条线上展示它们。有可能吗
我在 Google 上搜索了多行 sn-p 并找不到任何有用的信息,因此想出了自定义 InfoWindow 的想法。
2.下面显示的是我的自定义信息窗口,它给了我 NullPointerException
从 try-catch 循环中获取异常。我遵循了一些在谷歌搜索时发现的代码,但它不起作用。
private class MyCustomInfoWindow implements InfoWindowAdapter{
private View view;
public MyCustomInfoWindow(){
}
@Override
public View getInfoContents(Marker markr) {
// TODO Auto-generated method stub
return null;
}
@Override
public View getInfoWindow(Marker marker) {
// TODO Auto-generated method stub
view = getLayoutInflater().inflate(R.layout.mycustom_infowindow, null);
TextView marker_heading = (TextView)findViewById(R.id.marker_heading);
try{
String m_heading = marker.getId();
marker_heading.setText(m_heading);
}
catch(Exception exx){
Toast.makeText(getApplicationContext(), "getInfoWindow Error is " + marker_heading.length(), Toast.LENGTH_LONG).show();
}
return view;
}
}
我的习惯
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/marker_heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:typeface="serif"
android:textStyle="bold"
/>
</LinearLayout>
使用谷歌地图 V2
谁能告诉我哪里出错了。
【问题讨论】:
-
对于
Is it possible to make multiline snippet in InfoWindow,您可以添加单独的 TextView 以在单独的行中显示 LATTITUDE 和 LONGITUDE,或者如果您只想在 TextView 上显示,请使用换行符 -
关于编辑,当有人说
googling或googled时,没有理由更改为google,因为它会混淆含义。代码编辑更合适。
标签: android google-maps customization infowindow