Reputation: 2223
if(bigimageS.length()==0){
show_image.setImageBitmap(null);
}else{
show_image.setImageBitmap(decodeImage(bigimageS));
}
****************
public static Bitmap decodeImage(String arrayList_image) {
BufferedInputStream bis;
URL aURL;
try{
aURL = new URL(arrayList_image);
URLConnection conn = aURL.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
bis = new BufferedInputStream(is);
Bitmap bm = BitmapFactory.decodeStream(bis);
bis.close();
is.close();
return bm;
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
this is my code and i want to clear imageview.my problem is i am getting the image in bigimages String.i am adding the imageurl from w/s.in string bigimages.when i click on next btn after once image set then old image is not clear.so plz help i put condition but not working.plz help.
I am using the decodeimage for decode the image so is it any way to clear if there is no url in string..help me plz not solve yet
Upvotes: 3
Views: 10134
Reputation: 2287
It is simple as passing a 0 as the resource
show_image.SetImageResource(0);
Upvotes: 0
Reputation: 2223
finally i got the solution..i have simply set the blank like this bigimageS=""; before getdata(); method..
Upvotes: 0
Reputation: 128428
Agree with Pranav, but i think you can also access inbuild resources of Android itself.
Try:
imgView.setImageResource(android.R.color.transparent);
Upvotes: 0
Reputation: 684
create a blank /transparent png image from photoshop , and apply as your image background.
Upvotes: 4
Reputation: 1427
try this one code
for (int i = 0; i < imageneel.size(); i++) {
if(imageneel.get(i).trim().length() == 0){
show_image.setImageBitmap(null);
}else{
show_image.setImageBitmap(decodeImage(imageneel.get(i)));
}
}
Upvotes: 0
Reputation: 56925
You need to check the length of the url . If it is 0 then you have to set null to imageviwe.
Please try this.
if(imageneel.get(i).length() == 0)
{
show_image.setImageBitmap(null);
}
Upvotes: 1