1

I am using ButterKnife for my android project. I am able to bind all my views in fragment using Butterknife, but unable to setAdapter to my ListView using Butterknife. Though I can bind it up simply using ListView.setAdapter(m_adapter) but I want to do it using Butterknife only.

Any help ?

Note: I am not asking for binding views inside Adapter using Butterknife. What I am asking for is: How to set Adapter with ListView using Butterknife.

Saurabh7474
  • 450
  • 5
  • 12
  • @IntelliJAmiya: I am not asking for binding views inside Adapter. I am explicitly asking for **binding Adapter with ListView using ButterKnife**. – Saurabh7474 Jan 16 '19 at 10:23
  • Possible duplicate of [How to use ButterKnife inside adapter](https://stackoverflow.com/questions/40890185/how-to-use-butterknife-inside-adapter) – Rumit Patel Jan 16 '19 at 10:23
  • you can't set adapter using butter-knife. Butterknife only use for bind View and ViewGroup. – sushildlh Jan 16 '19 at 10:29
  • What you are asking is `Data Binding`. – ADM Jan 16 '19 at 11:03

1 Answers1

-1

You can pass your view to ButterKnife and bind it

@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;
}
Dewashish
  • 141
  • 1
  • 7