如何在Android Annotation中发送和接收意图中的ArrayList

时间:2016-10-01 17:22:27

标签: android-intent arraylist android-annotations

我正在尝试通过Android Annotation中的意图发送和接收ArrayList。我怎样才能做到这一点?

 grid.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                                    int position, long id) {
                SubcriptionAddPage_.intent(activity).startForResult(REQUEST_CODE);
                overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
            }
        });

1 个答案:

答案 0 :(得分:0)

Activity中,您可以像这样注入Intent额外费用:

@EActivity
public class SubcriptionAddPage extends Activity {

  @Extra
  ArrayList<String> arrayListExtra;

  @AfterInject
  void afterInject() {
    // you can use the injected extra here
  }

}

SubcriptionAddPage_.intent(activity)
  .arrayListExtra(list) // pass the extra to the generated builder
  .startForResult(REQUEST_CODE)
  .withAnimation(R.anim.activity_in, R.anim.activity_out); // you can use this instead of calling overridePendingTransition()