android – How to transfer already written code to Fragments?


Let's say I created some kind of program. But I got confused in the activation files. One part is displayed correctly, and the other is completely different. I can't display the right thing in the right place. Everything turned into a mess.

Googling, I read about the fragments. But I don’t know how to break the already finished code into pieces.

How to do it? How to transfer a finished working program into fragments?


Whether it will help or not, I don't know. Quite recently, a week ago, I rewrote my program for fragments. It used to be everything in MainActivity. I wanted to transfer everything to separate sheets where each had some part of the old activity. What did I do? First, I just added these very fragments and commented out everything that caused the error. Then he transferred it in parts. There were problems – questions of how to call the methods of activation from a fragment or vice versa. Using a search, I found all the answers. Slowly but surely everything was transferred. I thought it wouldn’t work, but I did it in 3 days, which is what I wish for you.

Scroll to Top