问题描述
i m使用所有类通过URL获取图像的所有类.
ImageView imV= ((ImageView) view.findViewById(R.id.badge)); // Image url String image_url = "http://maps.gstatic.com/mapfiles/place_api/icons/cafe-71.png"; final int stub_id = R.drawable.ic_action_search; // ImageLoader class instance ImageLoader imgLoader = new ImageLoader(getApplicationContext()); // whenever you want to load an image from url // call DisplayImage function // url - image url to load // loader - loader image, will be displayed before getting image // image - ImageView imgLoader.DisplayImage(image_url,stub_id ,imV);
但是它显示默认图像,而不是下载URL图像.
i m使用Goolge的InfowWindowAdapter类,它说我在窗口中加载数据和图像时不会更改图像,这就是为什么它显示首先显示默认图像.....且以后不更改
那么还有其他方法吗? 预先感谢
推荐答案
我遇到了同样的问题. 我已经用异步箱解决了.
像这样的东西
private Drawable _infoImageDrawable; public class MyMapActivity extends MenuActivity { .....code code code.... protected void handleMarkerClicked(final Marker marker, final String url) { new AsyncTask<Void, Void, Void>() { @Override protected void onPreExecute() { super.onPreExecute(); _infoImageDrawable = null; } @Override protected Void doInBackground(Void... params) { InputStream is; try { is = (InputStream) new URL(url).getContent(); _infoImageDrawable = Drawable.createFromStream(is, ""); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); marker.showInfoWindow(); } }.execute(); } }
然后,我只是将绘制的Infowdowadapter中的绘制设置为NULL(删除旧图像),然后将其设置为_imageInfodRawable的第二. 它有效 - 但我想要一个更好的解决方案.
问题描述
i m using all the classes for geting image through Url.
ImageView imV= ((ImageView) view.findViewById(R.id.badge)); // Image url String image_url = "http://maps.gstatic.com/mapfiles/place_api/icons/cafe-71.png"; final int stub_id = R.drawable.ic_action_search; // ImageLoader class instance ImageLoader imgLoader = new ImageLoader(getApplicationContext()); // whenever you want to load an image from url // call DisplayImage function // url - image url to load // loader - loader image, will be displayed before getting image // image - ImageView imgLoader.DisplayImage(image_url,stub_id ,imV);
but it is displaying the default image,rather than Url downloaded image.
i m using infowindowAdapter class of goolge and its says that i cn't change the image when once data & image is loaded in the window,thts why its displaying first default image..... and not changing later
so is there any other way? thanks in advance
推荐答案
I'm having the same problem. I've solved it with a asyncTask.
Something like this
private Drawable _infoImageDrawable; public class MyMapActivity extends MenuActivity { .....code code code.... protected void handleMarkerClicked(final Marker marker, final String url) { new AsyncTask<Void, Void, Void>() { @Override protected void onPreExecute() { super.onPreExecute(); _infoImageDrawable = null; } @Override protected Void doInBackground(Void... params) { InputStream is; try { is = (InputStream) new URL(url).getContent(); _infoImageDrawable = Drawable.createFromStream(is, ""); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); marker.showInfoWindow(); } }.execute(); } }
Then I just set the drawable in the InfoWindowAdapter to null first(remove old image) and to _imageInfoDrawable second. It works - but i would like a better solution.