5

私は今これについてたくさん読んでいて、新しい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」が定数式ではないのはなぜですか??

これを修正する方法を知っている人はいますか?

4

1 に答える 1