How to transfer values from activity to fragment without recreating it? Need to add an item:
date
public class DialogList { public String name; public String age; public int photoId; public DialogList(String name, String age, int photoId) { this.name = name; this.age = age; this.photoId = photoId; } } Fragment
private List<DialogList> persons; public void addItems(String word) { persons.add(new DialogList(word, "35 years", R.drawable.ic_launcher_foreground)); rv.getAdapter().notifyDataSetChanged(); } Activity
public void fragment(String agr){ MyFragment catFragment = (MyFragment) getFragmentManager().findFragmentById(R.id.frame_container); catFragment.addItems(agr); } Here addItems is red
xml Activities
<FrameLayout android:id="@+id/frame_container" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/relativeLayout"> </FrameLayout>