How to use ButterKnife inside adapter

后端 未结 3 1789
半阙折子戏
半阙折子戏 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 16:53

    You should pass your view to ButterKnife to bind it first.

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View v = LayoutInflater.from(context).inflate(R.layout.item_spinner, null);
        ButterKnife.bind(this,v);
    
        return v;
    }
    

    Then you will have access to your Views.

提交回复
热议问题