Answer the question
In order to leave comments, you need to log in
How can one implement passing the FirebaseDatabase.getInstance().getReference method from one fragment to another?
There are two buttons in the fragment. Each of them now leads to a fragment with a RecyclerView, but we need to make sure that completely different data is loaded into it depending on the button that was clicked. Data is loaded from Firebase using the getReference method. It turns out that when you click on the first button, it should work
mRef = FirebaseDatabase.getInstance().getReference("DataOne");
, and when passing through the secondmRef = FirebaseDatabase.getInstance().getReference("DataTwo");
Answer the question
In order to leave comments, you need to log in
Anchor link should look like this:
radioroomy.com/pyat-knig-o-lyubvi#two
Instead of:
radioroomy.com/#two
In modx, it is convenient to form a link in this way<a href="#two">...</a>
You can pass the required string in the following way:
- Create a static method in the fragment class to which we will pass the string
public static FragmentSimpleName newInstance(String line) {
FragmentSimpleName fragment = new FragmentSimpleName ();
Bundle args = new Bundle();
args.putString("line", line);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String line = getArguments() != null ? getArguments().getString("line") : "DataOne";
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question