Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAkshay Shivpuri
2,917 PointsError in mainactivity.java after deleting framelayout.xml
Receiving error in this line
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
Error states
Multiple markers at this line
- container cannot be resolved or is not a field
- The method add(Fragment, String) in the type FragmentTransaction is not applicable for the arguments (Fragment,
MainActivity.PlaceholderFragment)
1 Answer
J Andrew Scott
30,626 PointsWhen you modify (or add/delete) layout files, your R class gets regenerated. Chances are R.id.container no longer exists. Your current layout needs to have an element in your current layout with the property android:id="@+id/container"