I'm making a Pulse kind of UI for my app. For this I'm using HorizontalListView
class as given here. However, this class has performance issues and delivers a noticeable lag.
To confirm this I assessed it using TraceView Profiler
and found that this class doesn't reuse views altogether and calls inflate()
method for every call inside getView()
.
Here is how I'm designing the adapter:
public View getView(final int position, View convertView, ViewGroup parent) {
final BaseAssets baseAsset = baseAssetsList.get(position);
if (convertView == null) {
viewHolder = new ViewHolder();
convertView = inflater.inflate(R.layout.gallery_list_item, parent, false);
viewHolder.newLabel = (ImageView) convertView.findViewById(R.id.iv_new);
viewHolder.assetImage = (ImageView) convertView.findViewById(R.id.iv_thumbnail);
convertView.setTag(viewHolder);
} else
viewHolder = (ViewHolder) convertView.getTag();
}
class ViewHolder {
ImageView newLabel;
ImageView assetImage;
}
Am I doing anything wrong? If not, please suggest me workarounds to improve performance. Possibly some other library you would have tried or any way to reuse views in my current library. Thanks !