position of ViewPager item with Data Binding

后端 未结 3 638
广开言路
广开言路 2021-01-13 11:56

I have implemented ViewPager with use of android Data Binding, it is working perfect with data and click events.

I have created interface f

3条回答
  •  庸人自扰
    2021-01-13 12:37

    You can pass view in interface

     public interface ItemClickListener {
         public void onItemClick(View view);
      }
    

    Than set position in tag which you already doing

    binding.getRoot().setTag(position);
    

    And than you can get position from that view param like this

    @Override
    public void onItemClick(View view){
      int position=(int)view.getTag();
    }
    

    For more detail info you can refer http://developers-club.com/posts/267735/

提交回复
热议问题