How to use Viewbinding in Android Java ListView


how to use view binding in android list view? I know how to use it in Recycler View, but don’t know how to use it in list view


Since list view provides raw views instead of viewholders you have to use another way to hold viewbinding, for example you can use view tags.

Create new ID in any of your resource files (like values.xml):

<id name"viewBinding" />

Then spawn view binding in your adapter (modified sample from docs):

private class MyAdapter extends BaseAdapter {

      // override other abstract methods here

      public View getView(int position, View convertView, ViewGroup container) {
          ItemViewBinding binding;
          if (convertView  null) {
              binding  ItemViewBinding.inflate(getLayoutInflater(), container, false);
              convertView  binding.getRoot();
              convertView.setTag(, binding);
          } else {
              binding  ((ItemViewBinding ) convertView.getTag(;


          return convertView;

Answered By – Pawel

Leave a Comment