匕首和ButterKnife Android的区别 [英] Difference between Dagger and ButterKnife Android

查看:127
本文介绍了匕首和ButterKnife Android的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以指出匕首和Butterknife之间的差异。我知道,Butterknife一种观点注射图书馆和匕首是一个依赖注入库。但是,在线文档似乎有点开销我。据Butterknife文档,你可以做非活性注射为好,这正是匕首呢?还是我误解的东西吗? 如果任何人都可以解释简单来说,两者之间的差异将是巨大的。 谢谢!

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 documentation online seems a bit overhead for me. According to Butterknife documentation you can do non-activity injections as well, which is what dagger does? Or did i misunderstood something? If anyone can explain the differences between the two in simple terms it would be great. Thanks!

http://square.github.io/dagger/

http://jakewharton.github.io/butterknife/

推荐答案

ButterKnife是有针对性地只注入意见。非活动注入只是意味着你可以提供自己的看法根注入的意见(如使用手动充气的观点,等等)。 匕首是一个有点复杂。只要你指定它可以注入任何你想要的模块 - 类满足这些依赖(或者你可以使用构造函数注入)

ButterKnife is targeted to inject views only. Non-activity injection just means that you can provide your own view root to inject views from (like with manually inflated views, etc.). Dagger is a bit more complicated. It can inject anything you want as long as you specified Module - class which satisfies those dependencies (alternatively you can use constructor injection).

作为一个底线 - 我想说ButterKnife可以帮助你避免所有的样板$ C $下创建视图(又名(TextView中)findViewById(R.id.some_text_view); 。仅此而已。引擎盖下它仍然没有一切无聊code,所以它不是一个真正的注入。

As a bottom line - I would say ButterKnife helps you to avoid all that boilerplate code for creating views (aka (TextView)findViewById(R.id.some_text_view);. Nothing more. Under the hood it still does all that boring code. So it is not really an injection..

另外值得一提的是杰克·沃顿是开发商为那些很酷的库之一:)

Also it worth mentioning that Jake Wharton is one of the developers for both those cool libs :)

下面是一些有用的链接:

Here is some useful links:

在GitHub上匕首示例项目

匕首$上Devoxx p $ psentation(杰克沃顿商学院)

匕首住处用匕首开发者

没有太多有用的ButterKnife链接。它非常简单和直截了当的,所以希望你不需要任何

Don't have much of useful ButterKnife links. It really simple and straight forward though, so hopefully you don't need any

这篇关于匕首和ButterKnife Android的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆