how load image from sqlite database into android view pager - android

I want to load image from SQLite DB in my android app and set its values into a image slider (viewpager) similar this tutorial :
http://www.thecrazyprogrammer.com/2016/12/android-image-slider-using-viewpager-example.html#comment-49936
please help !

You first need to save your images in database in form of byte[] and then retrieve one by one in your pager adapter then convert byte[] to Bitmap and set in ImageView. But this is not a good practice.
If your images are static then you should store them in drawables as shown in that tutorial and if your images are dynamic and fetched from network you should use Picasso, Glide or any such library to load those images directly from network into your ImageView.
This tutorial might help you in integrating Picasso library.

Related

Fetching an Image through a viewpager

Is it possible to fetch an image and to store it in an ImageView from a viewPager using a particular position?
I tried to store in bitmap using drawableCache(), but it didn't help me.

loading different offline images (default images ) in NetworkImageview Volley android

What I have
I have GridLayoutManager Recyclerview which has positions 0,2,5,7 fixed with custom images (relative layout converted to bitmap ;) ) , rest positions are filled with images from server using volley's setImageUrl()
What I want
I wanted the GridLayoutManager Recyclerview to show offline images from my drawable folder using setDefaultImageResId() till the images from server loads
My problem
How do I set different default images even when there is no images from server reason (when there is no data from server , the GridLayoutManager Recyclerview doesn't populates cells) , still I wanted to show default images (mini 4 cells required)
temporary trick I did
I upploaded my 4 defaults images in dummy server to force GridLayoutManager Recyclerview to generate cells and showing it using volley's setImageUrl()
My expected result
I think that Volley has the option to display a default image and a image if an error has occurred.
NetworkImageView niv = (NetworkImageView)findViewById(R.id.niv);
if(url.length() > 0)
niv.setImageUrl(url, imageLoader);
niv.setDefaultImageResId(R.drawable._default);
niv.setErrorImageResId(R.drawable.error);
You can use the Picasso library for loading the images from the server. Using Picasso, you can determine an image to be shown in case of a network error, or if no data is available.
Picasso.with(context).load(url).error(R.drawable.error_or_defaultimage).into(R.id.imageview,callback) ;
Here's a tutorial on using Picasso.

Downloading image from web takes too much of time in Listview

Hi in my application i need to download some images and text from the web and need to display in listview. for that i'm using POJO class means initially storing all the images in to the POJO class and then display in listview
It is good for less images but while downloading more than 100+ plus images it taking too much of time to load,
can anybody suggest some good solution for this.
You can use the following libraries which are able to do lazy loading :
UrlImageViewHelper
Universal Image Loader
Picasso
All these libraries are lazy loading ready which means these libraries can reuses views in widgets like ListView and GridView.
Try to use AsyncTask() method.Since it is doing its process in background it may work quicker.

Display Thumnail URI in image icon from server

I want to display thumbnail image as image icon in ListView.
I am using array list that contains all thumbnail images path, these path will be accessed from the server.
My arraylist as ahown below.
mylist=['a1','a2','/playback/2012/a1.jpg','b1','b2','/playback/2012/000_b1.jpg', .....]
In this nearly 15 paths are there.. Now i want to display these images in listview.
'a1' is videoName 'a2' is categoryName and one more is path.
These path will be accessed from server only.. I think, we can't store it in drawable.
These are always changing.
How to solve it?
Please help me.
Use ImageView in the layout for ListView items and load images as described here:
How to load an ImageView by URL in Android?
and optionally here:
Lazy load of images in ListView

ListActivity Item with remote image

I have a ListActivity that should display quite a lot of items and where each list item should contain a text and and an image. The images are gotten from a remote server. How can I display the remote image on the list item. Thanks in advance
Download the images into memory or a local cache using HttpURLConnection or similar then use BitmapFactory.decodeByteArray to convert the downloaded images into bitmaps and assign them to ImageViews using setImageDrawable to display them.

Categories

Resources