【发布时间】:2012-07-20 22:16:48
【问题描述】:
我现在阅读了很多关于这方面的内容,并且我发现了如何使用新的 ADT 的 switch 语句来赋予常量表达式的示例,但没有提到关于 @Inject 的所有内容。
这是我有问题的代码的示例。
import roboguice.inject.InjectView;
public abstract class YpListActivity extends GuiceListActivity
@InjectView(R.id.btnSearch)
Button btnSearch;
@InjectView(R.id.btnSpeech)
View btnSpeech;
@InjectView(R.id.etWhat)
EditText etWhat;
@InjectView(R.id.etWhere)
EditText etWhere;
@InjectView(R.id.tvIn)
TextView tvIn;
@InjectView(R.id.tvLocation)
TextView tvLocation;
@InjectView(R.id.tvCustom)
private ToggleButton tvCustom;
@InjectView(R.id.infoButton)
private ImageView iconButton;
每次我尝试使用 @injectView(R.id.*) 之类的东西时,eclipse 都会抛出错误:
“注解属性InjectView.value的值必须是常量表达式。”
我什至尝试将其更改为:
private static final int btnsrch = new Integer(R.id.btnSearch);
@InjectView(btnsrch )
TableRow btnSearch ;
“btnsrch”怎么不是常量表达式??
有人知道如何解决这个问题吗?
【问题讨论】:
-
改变 Java 语义,我猜。
标签: android eclipse google-api