Search code examples
androidandroid-activityandroid-pageradapter

Passing a list of objects to a PagerActivity


I have a list with articles taken from an List and want to show the selected article in a PagerActivity so the user can easily flip to the article before and after when finished reading.

In iOS I can just pass the List (or a reference) with article objects to the PagerActivity. In Android however, calling on an Intent does not allow Lists to be passed on. So what would be the best way of doing it? Do I need to reload the array in the next Activity and then pass the position as an argument to the Intent?

(Reloading the List would be expensive, but should work if the DB hasn't changed since loading, otherwise the order might be different and the wrong item might be shown).


Solution

  • In Android

    Used ParecleObjectif you have Custom Object ArrayList and if your have simple String ArrayList then pass directly in Intent

    If you have Simple String ArrayList then refer below

    Passing ArrayList of string arrays from one activity to another in android

    and If you have Custom Object ArrayList then refer below

    How to pass ArrayList<CustomeObject> from one activity to another?

    Passing arraylist of objects between activities