Annotations Attribute does not accept my variable

Iv'e read a lot about this now, and I found examples of how constant expressions should be provided with the new switch ADT statements, but nothing is mentioned about every @Inject application.

Here is an example of my problematic code.

 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;

Every time I try to use something like @injectView (R.id. *), eclipse throws an error:

"The value of the InjectView.value annotation attribute must be a constant expression."

I even tried changing it to this:

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

     @InjectView(btnsrch )
     TableRow btnSearch ;

How is “btnsrch” not a constant expression?

Does anyone know how to fix this?

+5
source share
1 answer

Remove "private" and it should work correctly.

0
source

All Articles