ListView custom layout

In the ListView im fetching user comments from my web API as JSON.

In my custom layout I added an ImageView which is optionally, because it only appears when the user has post an image.

Is it good as performance to use an empty ImageView in my layout with an ID? When the URL for image is empty it won’t happen something, but when it contains an URL, I will change the image resource to the bitmap with an image loader library.


You can use a default image if at all there is no image returned in your JSON response. Else you can also hide the visibility of imageview by,

if(TextUtils.isEmpty(imageUrl)) {

Also since you are using a listview even if there are too many items, since the same views will be reused there will be no much memory and performance issues.