【问题标题】:How to send and receive ArrayList in intent in Android Annotation如何在 Android Annotation 中发送和接收 Intent 中的 ArrayList
【发布时间】:2016-10-01 17:22:27
【问题描述】:

我正在尝试通过 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);
            }
        });

【问题讨论】:

    标签: android-intent arraylist android-annotations


    【解决方案1】:

    在你的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()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-04-06
      • 1970-01-01
      • 1970-01-01
      • 2017-05-29
      • 2016-11-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多