图像不从自定义URL信息窗口加载在Android中使用毕加索的图像加载库 [英] image not loading from URL in custom infoWindow using Picasso image loading library in android
问题描述
我想自定义信息窗口从URL加载图像时的标记,用户点击。我可以加载其他的细节,但图像没有加载INT它。我使用的毕加索库来帮我这个忙。我搜索到很多相关的话题,看到了解决方案,但无法理解适用于解决我的问题,这解决方案。我使用的是Web服务调用来获取所需的数据。
I am trying to load an image from the URL in custom infoWindow when the user click on the marker. I was able to load the other details but the image is not loading int it. i'm using Picasso library to do this for me. I have search many related topics and see the solutions but was not able to understand which solution to apply to solve my problem. I am using an web service call to get the required data.
这是我的code:
@Override
public View getInfoContents(Marker arg0) {
//marker.showInfoWindow();
return null;
}
@Override
public View getInfoWindow(Marker arg0)
{
View v = getLayoutInflater().inflate(R.layout.map_infowindow, null);
for(int i=0 ; i<lstMain.size();i++)
{
Pojo b=lstMain.get(i);
double slat= Double.parseDouble(b.getLatitude());
double slng= Double.parseDouble(b.getLongitude());
double lat= Math.round(slat*100000.0)/100000.0;
double lng= Math.round(slng*100000.0)/100000.0;
String s1=String.valueOf(lat);
String s2=String.valueOf(lng);
Log.v("comparing latilongi pojo===>", lat+" , "+lng);
Log.v("comparing latilongi marker===>", Clickedlatitude+" , "+Clickedlongitude);
if(s1.equals(String.valueOf(Clickedlatitude)) && s2.equals(String.valueOf(Clickedlongitude)))
{
txtDname=(TextView)v.findViewById(R.id.infoDoctorName);
txtDspe=(TextView)v.findViewById(R.id.infoDoctorSpe);
txtDaddress=(TextView)v.findViewById(R.id.infoDoctorAddress);
imgUrl=(ImageView)v.findViewById(R.id.infoDoctorImage);
String url=b.getPhotoURL();
txtDname.setText(b.getDoctorName());
txtDspe.setText(b.getSpecialization());
txtDaddress.setText(b.getAddress1()+" , "+b.getAddress2());
Picasso.with(MapActivity.this)
.load(url)
.placeholder(R.drawable.ic_launcher)
.error(R.drawable.ic_launcher).resize(50, 50)
.into(imgUrl);
}
}
return v;
}
我已经看到了这些解决方案,但不明白到底是什么将解决我的问题:
I have already seen these solutions, But not understanding exactly what will solve my problem:
<一个href="http://stackoverflow.com/questions/16662484/why-custom-infowindow-of-google-map-v2-not-load-url-image">Why的谷歌地图V2自定义信息窗口,不加载URL图像?
<一个href="http://stackoverflow.com/questions/14334390/android-google-maps-apiv2-infowindow-and-markers">Android谷歌地图APIv2信息窗口和标记
<一个href="http://stackoverflow.com/questions/18938187/add-an-image-from-url-into-custom-infowindow-google-maps-v2">Add图像从URL到自定义信息窗口谷歌地图V2
推荐答案
您可以使用一个毕加索回调的onSuccess加载图像,像这样
You can use a Picasso Callback onsuccess loading the image, like this
if (image != null) {
Picasso.with(getApplicationContext())
.load(image)
.placeholder(R.drawable.ic_launcher)
.into(i, new MarkerCallback(marker));
}
和创建一个新类来处理毕加索回调这样MarkerCallback.java
and create a new class to handle the Picasso Callback like this MarkerCallback.java
public class MarkerCallback implements Callback {
Marker marker=null;
MarkerCallback(Marker marker) {
this.marker=marker;
}
@Override
public void onError() {
Log.e(getClass().getSimpleName(), "Error loading thumbnail!");
}
@Override
public void onSuccess() {
if (marker != null && marker.isInfoWindowShown()) {
marker.hideInfoWindow();
marker.showInfoWindow();
}
}
}
这篇关于图像不从自定义URL信息窗口加载在Android中使用毕加索的图像加载库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!