Send data from activity to fragment in Android

前端 未结 20 2711
悲哀的现实
悲哀的现实 2020-11-21 05:13

I have two classes. First is activity, second is a fragment where I have some EditText. In activity I have a subclass with async-task and in method doInBa

20条回答
  •  感动是毒
    2020-11-21 05:33

    the better approach for sending data from activity class to fragment is passing via setter methods. Like

    FragmentClass fragmentClass = new FragmentClass();
    fragmentClass.setMyList(mylist);
    fragmentClass.setMyString(myString);
    fragmentClass.setMyMap(myMap);
    

    and get these data from the class easily.

提交回复
热议问题