How to use ButterKnife inside adapter

后端 未结 3 1783
半阙折子戏
半阙折子戏 2021-02-13 16:30

I would like to use ButterKnife to bind my views inside listView adpater.

I tried this, but i can not simply use my \"spinner\" var.

public class WarmSpi         


        
3条回答
  •  温柔的废话
    2021-02-13 17:09

    ButterKnife is binding your view to the ViewHolder class, so WarmSpinnerAdapter won't be able to access it directly. Instead, you should move this part inside the ViewHolder class:

    @OnClick(R.id.spinner)
    public void onClick() {
        //open dialog and select
    }
    

    From there, you could either call an internal method from the adapter or execute the logic directly inside the ViewHolder

提交回复
热议问题