ADT blank activity created with fragment activity..

Christian Burgos picture Christian Burgos · Mar 9, 2014 · Viewed 44.3k times · Source

i am really confused right now because whenever i create a new android app with blank activity it always comes out with fragment_main.xml.. i just wanted to create a blank activity without the fragment one...

in the first image the blank activity comes with the fragment layout..

first image blank activity

the second image shows the created fragment_main

second image blank activity

now i am really confused... this only happened after updating ADT to the latest version i have referred to this thread: https://stackoverflow.com/questions/22203862/adt-doesnt-create-default-hello-world-but-command-line-does#=

i just wanted to make an android app with blank activity with no fragment view...

Answer

Ben Jakuben picture Ben Jakuben · Mar 18, 2014

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.