K
K
Kernokus2020-04-30 17:13:58
Java
Kernokus, 2020-04-30 17:13:58

How to make a common variable for two fragments?

Good afternoon. There is a RecyclerView in Fragment #1 and Fragment 2 with a couple of buttons. Both fragments are inside ViewPager. From Fragment #1, by clicking on the button, I can add items to the RecyclerView, but I want to do this from Fragment #2. That is, by pressing a button in the fragment, create one item for the Recyclerview and place it without going to the fragment with the RecyclerView. My idea is to make a generic adapter, set it in a fragment with a RecyclerView, and add items in a fragment without a RecyclerView. What's the best way to do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timur Pokrovsky, 2020-04-30
@Makaroshka007

https://metanit.com/java/android/8.5.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question