Answer the question
In order to leave comments, you need to log in
Activity or fragment (android)?
There is such a question. Once I played with fragments and wanted to do this: there is an activity, there is a fragment in it, we press the button in the fragment and this fragment is replaced with a new one. But errors flew out and I realized by googling that this is impossible.
But recently I looked at how Telegram and WhatsApp work. What I was talking about was implemented in Telegram (either the activity does not appear there as standard, or everything is displayed there without layouts, immediately programmatically and when you click on the interlocutor, it is programmatically replaced). Whereas in Watsap everything is simple.
Please explain to me how they did it and what are the differences.
Answer the question
In order to leave comments, you need to log in
FragmentManager fragmentManager = getActivity().getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
ExampleFragment fragment = new ExampleFragment();
fragmentTransaction.add(R.id.fragment_container, fragment);
fragmentTransaction.commit();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question