I’m having a weird problem, and not sure why. I have a main activity with 2 fragments that split the screen. The left fragment will be static, but the right side needs to change layouts based on user actions.
I’m using REPLACE, but it’s creating a new fragment right under fragment2 (right side) and then that is the one that seems to change.
I’m wondering if it’s because in my Main activity I’m using setContentView(R.layout.main);
where the Main.xml is laying out Fragment1 and Fragment2?
So my question is: should I be adding my fragments programmatically instead of relying on the base layout?
I really would like to see an example of the best way to do what I’m trying to do. All of the ListFragment examples I’m seeing online is not really doing what I need, because when you click on an item in the list, the other fragment is just displaying different content with the same layout.
You can replace only dynamic fragments, not layout ones. So add your replaceable fragment from code.