Search code examples
androidlistviewimageviewlazy-loadingandroid-lazyloading

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.

enter image description here

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


Solution

  • 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.