How to prevent Eclipse from creating fragment_main.xml

I installed Eclipse on a new machine and it keeps creating fragment_main.xml when I create a new Android Application Project. How can I prevent Eclipse from doing this, since I don't need a fragment_main.xml? I'd rather only have the activity_main.xml on start.

Answers


There's currently no way (as far as I know) to keep Android from creating a fragment when you create an Activity. You can uncheck the "Create Activity" check box and create a new Activity, but that's really all you can do.

Anyways, Fragments are good for Phone/Tablet Compatibility, and should be used in almost all scenarios except for very basic uses.


1.Creat project normally.

2.Copy fragment_main.xml to activity_main.xml (content). Then delete fragment_main.xml

3.In MainActivity.java delete the following content :

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

and

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

enjoy it.


Need Your Help

Is it possible to return an array from Java to C++ through a return value of a method?

java c++ arrays java-native-interface return

I know that one can pass an array from Java to C++ by native methods, but in that case you have to run the Java code.

Clicking on iFrame does not blur Ext Combobox

javascript iframe extjs combobox onblur

I have a page with a Ext.form.ComboBox and a TinyMCE Editor, which uses an iframe for its body. The problem is that when the ComboBox has focus and the user clicks on the iframe, the ComboBox's blur