Here I’ll show you how to quickly fix the Android Fragment error that many people are having trouble with. This fix will work with every part of my Android video tutorial.
I have both a video as well as a step-by-step list below on how to fix it. While my current Android tutorial is still very current I’m also planning on making another Java Android tutorial very soon. I just wanted to get this quick fix out as soon as possible.
If you like videos like this, it helps to tell Google Plus with a click here [googleplusone]
Fix Android Fragment Error Step-by-Step
Fix Android Fragment Error 1. Copy everything in res/layout/fragment_main.xml 2. Paste everything from res/layout/fragment_main.xml over everything in res/layout/activity_main.xml 3. Delete res/layout/fragment_main.xml 4. In MainActivity.java delete the following In onCreate if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction() .add(R.id.container, new PlaceholderFragment()).commit(); } And... public static class PlaceholderFragment extends Fragment { public PlaceholderFragment() { } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } 5. Comment out all unused imports to make all warnings go away.
Hi Derek,
It great that you are continuing with the android tutorials, would you please cover google api like map view, geocoder and maybe some media stuff like placing images from mediastore on map based on their meta data
I will keep making videos until I cover everything. I just got distracted last time because I made to complex a tutorial series.
we dont need to replace the “.. extends ActionBarActivity”
with “… extends Activity” ?
Would like to see a tutorial using the newer implementation of fragments.
I’m going to start a brand new Android tutorial in less then 2 weeks 🙂