Home  >  Q&A  >  body text

java - How to bind multiple views in butterknife

View view = View.inflate(context, R.layout.news_item_pager, null);
ButterKnife.bind(this, view);
View rollView = View.inflate(context, R.layout.layout_roll_view, null);
ButterKnife.bind(this,rollView);

Why does it report an error when written like this? How does butterknife bind multiple views?

天蓬老师天蓬老师2667 days ago628

reply all(1)I'll reply

  • 世界只因有你

    世界只因有你2017-06-30 09:55:10

    When multiple Views are bound to the same class, the annotation processor will look for the id name corresponding to the binding reference in each View. If it cannot find it, an error will be reported.
    It is recommended not to bind multiple Views in the same class. You can bind them in inner classes

    reply
    0
  • Cancelreply