我是android app开发者的初学者,我见过很多使用@bind和@inject的开源应用程序,也默认@override
我想知道那些是什么,有什么不同。@ Inject LessonCatalogActivityPresenter lessonCatalogActivityPresenter;
@Inject
MarketService marketService;
@Inject
ShareService shareService;
@Bind(R.id.toolbar)
Toolbar toolbar;
@Bind(R.id.sliding_tabs)
TabLayout tabLayout;
@Bind(R.id.view_pager)
ViewPager viewPager;
@BindString(R.string.title_activity_lesson_catalog)
String title;
@Bind(R.id.fab)
FloatingActionButton floatingActionButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lesson_catalog);
ButterKnife.bind(this);
initToolbar();
initTabs();
initTitle();
lessonCatalogActivityPresenter.setView(this);
lessonCatalogActivityPresenter.initialize();
}
private void initToolbar() {
setSupportActionBar(toolbar);
}
private void initTabs() {
viewPager.setAdapter(new LessonsPageAdapter(getFragmentManager()));
viewPager.setOffscreenPageLimit(OFF_SCREEN_PAGE_LIMIT);
tabLayout.setupWithViewPager(viewPager);
viewPager.addOnPageChangeListener(this);
}
private void initTitle() {
getSupportActionBar().setTitle(title);
}
@Override
public void injectActivity(ActivityComponent component) {
component.inject(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;`
答案 0 :(得分:2)
@Override
注释表示此方法存在于其超类之一中,请参阅此javadoc
在您的示例中,ButterKnife使用@Bind
注释将您的实例变量viewPager,tabLayout ..映射到各自的UI组件
我认为@Inject
是Dagger用于在您的服务中应用依赖注入的var buff = new Buffer(_msg.content);
_msg.content = AES.decrypt(clients.getKeyOf(_msg.clientID), '', buff).toString('utf8');
但我们无法确定如何不查看顶部的导入类