Eucar Eucar - 6 months ago 9
Android Question

ListView custom layout

In the ListView im loading user comments from my web API with JSON.

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

Question: Is it good as performance to use an empty ImageView in my layout with an ID? When the url for image is empty it will not 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.