listview scrolling with images - android

In my app,i have a listview with image and text.when the user clicks in the listview,the image in that row will change.the problem is when user scrolls the listview.the changed image is not showing.but later it is appearing...please provide me a solution or code to avoid this.
thanks in advance..

What's the size of the images that are used for each item in the listview.
When scrolling the image needs to be redrawn and if the images are of a larger size it can take time to redraw.
Make sure the images are only as big as they need to be for the item

Related

Image loading is slow. Need to load only visible images

I am loading an image from memory into a RecyclerView. Not api call. From phone memory.
Each item in the RecyclerView has an image.
The images are loaded only when i scroll to them. Now the problem is, when i scroll fast to the 10th item, all 10 items are loading. When i view the 10th item, the 1-8 items are not visible in the device screen yet they are loading. How to prevent this. So when i see the 20th item, it is taking around 1 minute to load.
What I want is, load only visible images. When i scroll fast to the 20th item, load only the 20th item. 1-19 and 21-... should not load
Try not to load the image in original size in RecyclerView. This severely freezes the UI.
It is better to use thumbnail images to display in recycleview.
Consider the following example:
Glide
Glide.with(context).load(image_file).thumbnail().into(imageView)

Lazyloading like googlenewstand app

I am currently doing a project which needs to load images in a listView with some text from web.I am using universal image loader library,every thing work fine images are loading perfectly without any problem, but my requirement is that if there is no image in a specfic url, i dont want to show that image view in the listview row.which is similer to the news stand app of google.
in the above screen of the newsstand app if there is no image the imageview is not shown and the text will fill to the total width of the cell or row in the listview.How can i achieve this requirement.i have goggled but did not get any right solution or clue to fix this issue,can any one give any snippet or any idea to sort out this issue.
Thank you
In your adapter, when you call the library to display the image, if there is no image url just set the visibility of your ImageView to GONE (and VISIBLE again when there is an url).
If you want to wait that the image is completely loaded to make the ImageView visible, you'll need to register a loading listener. See here.

android dynamically show list with text and images, improving performance

I need to display a list of items each with text and various number of images.
I'm currently using a ListView with custom adapter to show these items. And for each item, I used a HorizontalScrollView with a LinearLayout in it to display the images. In the getView method of the ListView, I read the image URIs of each item and dynamically create ImageViews, then load the images asynchronously. I used a ViewHolder to hold the LinearLayout which contains all the ImageViews of each item.
The problem is, if I scroll down the ListView and scroll back, I'll lost the content of the item, which means I have to load the images again. And most of the images are too large and loads very slow. Actually on my app the screen can show only about 2 or 3 items once, so the scroll happens very frequently.
I have some ideas to improve this, but I'm not sure whether one of them will results better.
Since I'm just showing a thumbnail of each image, maybe I can save the thumbnails into a temp dir and load them dynamically, loading small images will be much faster. And I might have to clear that temp dir when it gets large.
I have at most 9 images for each item, so it might still be slow even if I cache the thumbnails and scroll frequently. And maybe I have to show the list manually instead of using ListView, so each item will not be reused, and the load will happen only once. But, the list will grow large in the future, if I preserve like 100 items in the LinearLayout my app may still crash.
Other better options...
Any advice will be helpful! Thanks!
You can use LazyLoading to display your image. You can use Universal Image Loader for this purpose. What lazyloading does is download an image once, cache it and display the image from cache during subsequent requests.

Android Simple Gallery Focused Item Issue

I have a gallery that I use to display some ImageViews. I'd like to know which image in the gallery is currently highlighted/focused.
So far, setOnItemClickListener only fires if I actually click on the images. If I scroll through the images, a new image takes focus. I want to know which image that is.
How can I do this?
Get the images number in the list
Get the image (view) it self

scrolling issues in gridview when displaying a large number of images in android

I want to display a large number of images(say 500).i am currently displaying them in a scrollable grid layout by lazyloading images(very similar to fedor's lazylist). but i am having issues while scrolling the grid. when i scroll the grid, the views get refreshed and the actual images are reloaded. so, even the images that were displayed earlier are refetched from SD card. this causes a very slow UI. is there any solutions for this.(i.e is there a way to tell the grid view not to refesh views on scrolling).
or
is there any other better way to display large number of images.
Thumbnails would speed things up a bit.
Check out: Android how to create runtime thumbnail

Categories

Resources