get value from custominfowindow on android google maps v2? -
i implement tutorial show custominfowindow google maps v2 on android device here code in mainactivity.java
final marker hamburg = googlemap.addmarker(new markeroptions().position(hamburg) .title("hamburg")); markers.put(hamburg.getid(), "http://img.india-forums.com/images/100x100/37525-a-still-image-of-akshay-kumar.jpg");
and code below class custom infowindow in same file
private class custominfowindowadapter implements infowindowadapter{ private view view; public custominfowindowadapter() { view = getlayoutinflater().inflate(r.layout.custom_info_window, null); } @override public view getinfocontents(marker marker) { if (mapv2infowindow.this.marker != null && mapv2infowindow.this.marker.isinfowindowshown()) { mapv2infowindow.this.marker.hideinfowindow(); mapv2infowindow.this.marker.showinfowindow(); } return null; } @override public view getinfowindow(final marker marker) { mapv2infowindow.this.marker = marker; string url = null; if (marker.getid() != null && markers != null && markers.size() > 0) { if ( markers.get(marker.getid()) != null && markers.get(marker.getid()) != null) { url = markers.get(marker.getid()); } } final imageview image = ((imageview) view.findviewbyid(r.id.badge)); if (url != null && !url.equalsignorecase("null") && !url.equalsignorecase("")) { imageloader.displayimage(url, image, options, new simpleimageloadinglistener() { @override public void onloadingcomplete(string imageuri, view view, bitmap loadedimage) { super.onloadingcomplete(imageuri, view, loadedimage); getinfocontents(marker); } }); } else { image.setimageresource(r.drawable.ic_launcher); } final string title = marker.gettitle(); final textview titleui = ((textview) view.findviewbyid(r.id.title)); if (title != null) { titleui.settext(title); } else { titleui.settext(""); } final string snippet = marker.getsnippet(); final textview snippetui = ((textview) view .findviewbyid(r.id.snippet)); if (snippet != null) { snippetui.settext(snippet); } else { snippetui.settext(""); } //final string txtgambarpp=url; final textview txtgambarppui = ((textview) view .findviewbyid(r.id.txtimageppsource)); if (snippet != null) { txtgambarppui.settext(url); } else { txtgambarppui.settext("kosong"); } return view; } }
custominfowindow.xml (linearlayout)
<imageview android:id="@+id/badge" android:layout_width="50dp" android:layout_height="50dp" android:layout_marginright="5dp" android:adjustviewbounds="true" > </imageview> <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" > <textview android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="end" android:singleline="true" android:textcolor="#ff000000" android:textsize="14dp" android:textstyle="bold" /> <textview android:id="@+id/snippet" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textcolor="#ff7f7f7f" android:textsize="14dp" /> <!-- add textview show information image --> <textview android:id="@+id/txtimageppsource" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="source image"/> </linearlayout>
i success run app , show information inside infowindow, if want value title call marker.gettitle
, success return title, want add information in infowindow except title , snippet,so add xml textview (in case set id textview @+id/txtimageppsource
) , when run apps still myproblem want value textview infowindow event click?how achieve that,if want value title call marker.gettitle,so how txtimageppsource ?
thanks
Comments
Post a Comment