Add clickListner for button inside a cardView populated using a recyclerView

前端 未结 4 1451
予麋鹿
予麋鹿 2020-12-25 07:49

I have a cardView

card_contents.xml




        
4条回答
  •  萌比男神i
    2020-12-25 08:45

    Let's say you have:

    
    
        
    
            
    
            
        
    
    
    

    Note this part: android:onClick="onClickBotonBorrar"

    On your Activity add this:

    public void onClickBotonBorrar (View v) {
    //Do whatever you want when user clicks on your ImageButton
        }
    

    It is recommended not to have the click event inside your adapter but inside your activity.

    Note: It's similar for button

提交回复
热议问题