我想實現採用Android註解次年春天代碼列表:Android的註釋 - 注射超型
@Autowired
public initHandlerList(List<Handler> handlerList) {
// Do stuff with the list ...
}
我同時使用一個接口和一個類嘗試。
bean定義:
@EBean
public AbstractHandler implements Handler {}
試圖注入:
@Bean
public initHandlersList(List<AbstractHandler> handlersList) {
// Do stuff with the list ...
}
但總是得到了以下錯誤:
Error:(20, 5) error: org.androidannotations.annotations.Bean can only be used on an element annotated with @org.androidannotations.annotations.EBean
所以我想,因爲列表本身不帶註釋@EBean
它不能用作一個Bean ...任何方式來實現這個使用Android Annotati項?
謝謝!
這可能會有所幫助https://github.com/androidannotations/androidannotations/wiki/Enhance-custom-classes – Boldbayar
@Boldbayar謝謝,但我已經閱讀他們的維基,他們沒有顯示任何地方如何做這樣的事情。 。我猜這是不可能與他們的框架,我將不得不寫一些樣板代碼 – Nom1fan