Difference between Dagger and ButterKnife Android

前端 未结 5 1689
旧巷少年郎
旧巷少年郎 2020-12-07 12:47

Can anyone point out the difference between Dagger and Butterknife? I know that Butterknife is a view injection library and Dagger is a dependency injection library. But the

5条回答
  •  半阙折子戏
    2020-12-07 13:44

    @JakeWharton's answers it partially in the comment:

    TL;DR: They complement each other. Use Butterknife for injecting views, Dagger for the rest.

    If you use Dagger to try and inject views you're going to have a very bad time :) Try to think of Butter Knife as a means of binding views rather than injection. I only called it injection because all the RoboGuice converts were complaining about lack of "view injection" with Dagger. It's not really injection at all. Like the answer mentions, it's just a way to reduce boilerplate. Under the hood it's just calling findViewById like you would!

提交回复
热议问题