Passing ArrayLists in Android

前端 未结 2 2010
孤城傲影
孤城傲影 2021-01-12 21:03

I\'m trying to pass array lists between activities in Android. The lists contains strings. I\'ve read a lot about Parcelable. Would I need to create a Parcelable to pass a <

2条回答
  •  借酒劲吻你
    2021-01-12 21:12

    It depends on the type of arraylist

    • putIntegerArrayListExtra(String name, ArrayList value)

    • putParcelableArrayListExtra(String name, ArrayList value)

    • putStringArrayListExtra(String name, ArrayList value)

    • putCharSequenceArrayListExtra(String name, ArrayList value)

    Then you can read from you next activity by replacing put with get with key string as argument,eg

    myIntent.getStringArrayListExtra("arrayListName");
    

提交回复
热议问题