ADT blank activity created with fragment activity

For those who would like instructions on how to remove Fragments from the project:

1) Copy all the contents of res/layout/fragment_main.xml. Open activity_main.xml, delete the FrameLayout, and paste in the copied contents.

2) Delete fragment_main.xml

3) In MainActivity.java, delete the whole PlaceHolderFragment class:

/**
 * A placeholder fragment containing a simple view.
 */
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;
    }
}

4) Delete the following lines from onCreate():

if (savedInstanceState == null) {
    getSupportFragmentManager().beginTransaction()
            .add(R.id.container, new PlaceholderFragment()).commit();
}

At this point you should be all set to run the project.

Leave a Comment