当我选择GeoPoint时,我出现了一个膨胀的布局,膨胀的布局上有一个按钮,我似乎无法点击按钮,花了好几个小时试图找出原因并且有做到这一点无济于事。下面显示了调用膨胀布局的代码,并显示了按钮的onClick。
public View getInfoContents(Marker arg0) {
View v = getLayoutInflater().inflate(R.layout.place_detail, null);
String pos = arg0.getSnippet(); //get index of the marker data
Button accept = (Button) v.findViewById(R.id.button3);
accept.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Toast.makeText(getApplicationContext(),"HAPPY MAN", Toast.LENGTH_LONG).show();
}
});
try{
int ipos = Integer.parseInt(pos);
PlaceData data = mListPlaceData.get(ipos); //get the data by index
((TextView)v.findViewById(R.id.txtName)).setText(data.name); //show name of the place
((TextView)v.findViewById(R.id.txtHours)).setText("Hours: "+data.hours); //show hours of the place
((TextView)v.findViewById(R.id.txtCountry)).setText("Country: "+data.country); //show country of the place
((TextView)v.findViewById(R.id.txtAddress)).setText("Address: "+data.address); //show address of the place
((TextView)v.findViewById(R.id.txtPostCode)).setText("Postcode: "+ data.postcode); //show postcode of the place
}catch(Exception e){
}
return v;
}
});
}
答案 0 :(得分:2)
绘制的信息窗口不是实时视图。视图在返回时呈现为图像(使用View.draw(Canvas))。这意味着对视图的任何后续更改都不会被地图上的信息窗口反映出来。要稍后更新信息窗口(例如,在加载图像后),请调用showInfoWindow()。此外,信息窗口将不会考虑正常视图(例如触摸或手势事件)的任何典型交互。但是,您可以在整个信息窗口中收听通用点击事件,如以下部分所述。
来源:https://developers.google.com/maps/documentation/android/infowindows