The standard way to declare fragments in a xml layout file is
<LinearLayout ...>
<fragment class="com.example.SomeFragment"
</LinearLayout>
where SomeFragment is a java class defined like
class SomeFragment extends Fragment {
...
}
Lets say, I have 3 fragments; fragment1, fragment2, and fragment3. When the user launches the app, I show them fragment1, and when they click on a button, I replace the fragment1 with fragment2, etc.
What is the best approach to define the 3 fragments in a single layout xml file?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…