I\'m fairly new to Android, so this might have an obvious answer, but I can\'t seem to find it.
I\'m writing a version of a calculator app. I want to make it so tha
The problem here is that the fragment needs a container with a view id to reside within. Giving it a layout id will result in the error you saw.
You can add the fragment to your relative layout, but to do that properly you'll need to assign it appropriate layout parameters so that it can be placed. It would be easier to just create a FrameLayout within the relative layout that wraps its contents, and then add the fragment there.
Then
fragmentTransaction.add(R.id.FragmentContainer, fragment);