Android passing ArrayList to Fragment from Activity

前端 未结 2 1467
抹茶落季
抹茶落季 2020-12-17 01:11

Hi I want to send the data ArrayList to Fragment class ListContentFragment.

In MainActivity I am making a netw

2条回答
  •  无人及你
    2020-12-17 01:39

    I was also stuck with the same problem . You can try this. Intead of sending the arraylist as bundle to fragment.Make the arraylist to be passed,as public and static in the activity.

    public static Arraylist arraylist;
    

    Then after parsing and adding the data in the arraylist make the call to the fragment.In the fragment you can the use the arraylist as:

    ArrayList list=MainActivity.arraylist;
    

提交回复
热议问题