注释属性不接受我的变量

Ian*_*per 5 eclipse android google-api

我现在已经阅读了很多内容,并且我已经找到了如何使用新的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;
Run Code Online (Sandbox Code Playgroud)

每次我尝试使用像@injectView(R.id.*)这样的东西时,eclipse会抛出错误:

"注释属性InjectView.value的值必须是常量表达式."

我甚至尝试将其更改为:

     private static final int btnsrch = new Integer(R.id.btnSearch);

     @InjectView(btnsrch )
     TableRow btnSearch ;
Run Code Online (Sandbox Code Playgroud)

"btnsrch"如何不是一个常量表达式?

有谁知道如何解决这个问题?

Der*_*kyy 0

删除“私人”,它应该可以正常工作。