【发布时间】:2015-04-27 16:48:42
【问题描述】:
我正在尝试单击 Google 地图的“窗口”,但我的按钮不起作用,我认为这是处理程序的问题,因为它被封装了“@listener”(android 无法正常工作)但我具体不知道。
我要点击的代码在这里:
googleMap.setInfoWindowAdapter(new InfoWindowAdapter() {
// Use default InfoWindow frame
@Override
public View getInfoWindow(Marker arg0) {
return null;
}
// Defines the contents of the InfoWindow
@Override
public View getInfoContents(Marker arg0) {
View v = getLayoutInflater().inflate(R.layout.windowlayout, null);
LatLng latLng = arg0.getPosition();
TextView tvLat = (TextView) v.findViewById(R.id.tv_lat);
TextView tvLng = (TextView) v.findViewById(R.id.tv_lng);
tvLat.setText("Latitude:" + latLng.latitude);
tvLng.setText("Longitude:"+ latLng.longitude);
Button btn = (Button)v.findViewById(R.id.btn); // Here my button not work
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(GoogleMapActivaFind.this, "wow", Toast.LENGTH_SHORT).show();
}
});
return v;
}
});
【问题讨论】:
-
但我需要更多按钮,而不仅仅是 1.... 就像这个图像 stackoverflow.com/questions/15090148/…
-
好的,只看信息窗口,但我认为喜欢和不喜欢按钮不是为了点击,而只是显示信息
-
当你点击infowindow然后转到该地点的详细页面,然后点击喜欢和不喜欢按钮,你同意我的观点吗?
-
我同意,结构不同,但目标是有很多按钮。
标签: android google-maps listener