Google Maps v2 自訂地標訊息視窗(InfoWindow)
然後google map的部分要用setInfoWindowAdapter方法替換調原本adapter就可以了!
map.setInfoWindowAdapter(new CMuseumAdapter());
要自己實作一個InfoWindowAdapter介面
class CMuseumAdapter implements InfoWindowAdapter
{
@Override
public View getInfoContents(Marker m)
{
return null;
}
@Override
public View getInfoWindow(Marker m)
{
View infoWindow = getLayoutInflater().inflate(R.layout.cus_info_museum, null);
TextView name = (TextView) infoWindow.findViewById(R.id.museum_Name);
TextView addr = (TextView) infoWindow.findViewById(R.id.museum_Address);
TextView status = (TextView) infoWindow.findViewById(R.id.museum_PublicStatus);
TextView tel = (TextView) infoWindow.findViewById(R.id.museum_Telephone);
name.setText(arrayList.get(Integer.parseInt(m.getTitle())).get("Name").toString());
addr.setText(arrayList.get(Integer.parseInt(m.getTitle())).get("Address").toString());
status.setText(arrayList.get(Integer.parseInt(m.getTitle())).get("PublicStatus").toString());
tel.setText(arrayList.get(Integer.parseInt(m.getTitle())).get("Telephone").toString());
return infoWindow;
}
}
當然,layout檔案也就是.xml檔案是可以隨便你定義的
![[Android程式範例] GoogleMaps自定義InfoWindow [Android程式範例] GoogleMaps自定義InfoWindow](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAMC9o840s3LfDlBCVNeCB4uGYkKgvJPmuxEJNqiVHOZFd5qXEy09T__8iaI8ZRQZuhrL8p7t3zc97D3kt_-y-DEpj-lds3YEvKyIQVWqXv9hcP5qxu8lZkd0EXxJC607joiQJCJMzjUg/s640/2013111121213475.png)
沒有留言 :
張貼留言