Android ViewFlipper change background with image from URL how to - android

I'm trying to change a background image on my ViewFlipper... But can't get it to work... Do I have to download the image before set it to the ViewFlipper? .. I saw an example where the URL is used.. But I can't! .
this.vf.setBackgroundDrawable("http://path_to_background_image");

I found the solution myself...
Bitmap bg_img = BitmapFactory.decodeStream((InputStream) new
URL(webservice.getString("background_image_url")).getContent());
vf.setBackgroundDrawable(new BitmapDrawable(bg_img));

Related

Using frame by frame animation with Universal Image Loader

Is there any good way to use frame by frame animation AnimationDrawable using UIL library. AnimationDrawable accept only BitmpaDrawable . Is there any way to convert quickly to bitmaps my images or any maybe there is method like imageLoader.getBitmap, I haven't find anything like that.
Please help , I would be very grateful for any help .
Edit I have my images in assets folder. Maybe there any way to get bitmap from cache or something else . I need open new activity , maybe several times . I need to show animation from files , but if I use decode it takes a lot of time to decode them . Please suggest something
If your images are resources you can use this for obtain Bitmap:
Bitmap icon = BitmapFactory.decodeResource(context.getResources(),
R.drawable.icon_resource);
else, if you want donwload the image you can use this:
String name = c.getString(url);
URL urlAux = new URL(name);
ImageView prueba = (ImageView)v.findViewById(R.id.iv_prueba);
if (prueba != null) {
Bitmap bitmap =
BitmapFactory.decodeStream(urlAux.openConnection().getInputStream());
prueba.setImageBitmap(bitmap);
}
Hope it helps you.

displaying image in the imageview directly from the internet

I want to load an image which is located at the url "http://www.Karnatakatourism.org/mm/slide/chickmaglur_home.jpg" onto the imageview in Android.
Can anyone help me with the code to do the same?
You can use android query lib. http://code.google.com/p/android-query/wiki/ImageLoading
You just need to write
aq.id(R.id.imageview_profilee).image("your path");
You can use this one...
There many libs to do this, You can use Picasso.
Here an example of usage:
Picasso.with(context).load("http://www.karnatakatourism.org/mm/slide/chickmaglur_home.jpg").into(imageView);
Or you can use Universal Image Loader class
in which you can use by this one.
imageLoader.displayImage("http://www.karnatakatourism.org/mm/slide/chickmaglur_home.jpg", imageView, options);

JSOUP to display images in Image view using the URL

How can i use JSOUP to display images in Image view using the URL. Any sample code is available for that. I searched but i couldn't find out.
Please help me with any link.
Thanks.
fir make the connection with provided link then you can get the image with
imagesRec = document.select("img[src~=(?i)\\.(png|jpe?g|gif)]");
then
String imgSrcUrl = img.attr("abs:src"); // imagePath
the you will use the Picasso lib for displaying the url as image in imageView
Picasso.with(MainActivity.this).load(imgSrcUrl).into(logo);
and thats it
you would have to parse the url of the image from the tag and then put into a string or similar. this string you can then use to load your image into an imageView.

Android: Getting Drawable from URL not working for .jpg, only works for .png

I am working on and Android app that pulls a picture from an internet page (specifically xckd.com). I have it working wonderfully using code of this basic form (see below)
ImageView iv = new ImageView;
URL url = new URL(address);
InputStream content = (InputStream)url.getContent();
Drawable d = Drawable.createFromStream(content , "src");
iv.setImageDrawable(d)
I noticed when I was viewing some of their older comics the image would not show (but I was scraping the other information from the page properly so I know the url is correct). I determined that this result only occurs when the image is a .jpg file but works perfectly when it is a .png
I have Googled around plenty and I can't figure out why this is, is there a simple fix for this?
It's a known issue http://code.google.com/p/android/issues/detail?id=6066. Using FlushedInputStream solves it.

Android how to display and image from URL

I'm having trouble displaying SOME images on my android app. Just normal display image from certain URL. Some images works, some just doesn't work. For instance try displaying this image from URL:
http://img191.imageshack.us/img191/7379/tronlegacys7i7wsjf.jpg
It doesn't work. Doesn't even work in emulator.
Could it be the EXIF info for the image is problematic? Can anyone try to see they are able to display that image on android app, and share the code/method to display that image on screen?
Thank you!
Or you can try this ImageDownloader class from google. It´s works nice :) Is an AsynkTask that handle the download and set the bitmap to an ImageView.
ImageDownloader
Usage:
private final ImageDownloader mDownload = new ImageDownloader();
mDownload.download("URL", imageView);
You will have no problems displayin that image in a webview
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.loadUrl("http://img191.imageshack.us/img191/7379/tronlegacys7i7wsjf.jpg");
where are your image being displayed?
Make sure you have <uses-permission android:name="android.permission.INTERNET" /> in your AndroidManifest.xml. What code are you using to load the image?

Categories

Resources