【发布时间】:2012-03-08 23:06:21
【问题描述】:
我正在使用 Guice(Roboguice v2 与 Guice v3 完全相同),我对它有点陌生。
我有一个单身..
@Singleton
Accounts
{
public Account[] getAllAccounts()
{
// Stuff
}
}
而且我还有一个类需要在其构造函数中访问上述内容..
public class AccountListAdapter extends ArrayAdapter<Account>
{
public AccountListAdapter(Context c)
{
super(c, R.layout.account_list_row, R.id.accountName, accounts.getAllAccounts());
}
...
}
如何访问上面用作 super() 调用的最后一个参数的 Accounts 单例?因为构造函数将在创建任何实例变量之前执行。
谢谢!
【问题讨论】:
-
您是否在 Activity onCreate() 期间创建 AcountListAdapter?
标签: guice