D
D
dimasik1002002018-03-12 20:59:36
Java
dimasik100200, 2018-03-12 20:59:36

Transition by button from one activity to a fragment of another activity. How to implement?

There are two activities. The first activity has fragment1 and fragment2. Fragment1 has a button that launches the second activity, and it has a button that, when clicked, should open fragment2 from the first activity. How should I write the onClick of the button in the second activity so that fragment2 opens from the first one?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Gnoemes, 2018-03-12
@Gnoemes

Maybe I misunderstood, but I would do this:
1. Launch the second activity through startActivityForResult, when you click on the button (make a callback from the fragment to the activity)
2. In the second activity, when you click, put some meta information and destroy the activity
3. In the first activity, you intercept information in onActivityResult and add a second fragment based on it

D
Denis Zagaevsky, 2018-03-12
@zagayevskiy

Throw out the second activity, do it entirely on fragments.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question