How to prevent Eclipse from creating a fragment_main.xml object

I installed Eclipse on a new computer and continue to create fragment_main.xmlwhen I create a new Android application project. How can I prevent Eclipse from executing since I do not need fragment_main.xml? I would prefer only to run activity_main.xml.

+4
source share
2 answers

Currently there is no (as far as I know) that Android does not create a fragment when creating an Activity. You can uncheck the "Create Activity" box and create a new activity, but that’s really all you can do.

, , .

+4

1. .

2.Copy fragment_main.xml - activity_main.xml(). fragment_main.xml

3. MainActivity.java :

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

/**
 * 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;
    }
}

.

+9

Source: https://habr.com/ru/post/1531259/


All Articles