gpt4 book ai didi

java - 无法选择损坏的布局上的任何元素

转载 作者:行者123 更新时间:2023-12-02 05:55:26 26 4
gpt4 key购买 nike

当我选择一个 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;
}
});

}

最佳答案

The info window that is drawn is not a live view. The view is rendered as an image (using View.draw(Canvas)) at the time it is returned. This means that any subsequent changes to the view will not be reflected by the info window on the map. To update the info window later (for example, after an image has loaded), call showInfoWindow(). Furthermore, the info window will not respect any of the interactivity typical for a normal view such as touch or gesture events. However you can listen to a generic click event on the whole info window as described in the section below.

来源:https://developers.google.com/maps/documentation/android/infowindows

关于java - 无法选择损坏的布局上的任何元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23138036/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com