When ever i create a new project, the Fragment_main.xml file is added to my Layout folder and unlike in Eclipse it is this file that contains what is normally in the Activit
The Activity_main.xml contains the Layout for the FragmentActivity and the fragment_main.xml is the Layout for the fragment.
For more information to fragments and how you can use it.
Visit: http://developer.android.com/training/basics/fragments/index.html
If you are creating a new Project and it adds fragment_main.xml by default you must be selecting a layout by default. Maybe a pager/spinner layout?
Fragment_main is the same as activity_main. The names are just string labels and mean nothing in and of itself and are just changed for clarity by the IDE.
Have a read of this.
http://developer.android.com/guide/topics/ui/declaring-layout.html
just as Bytehawks said above.
activity_main.xml describes Layout for the FragmentActivity and the fragment_main.xml is the Layout for the fragment.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); //get the activity_main.xml for layout
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//code for describing layout more details, get fragment_main.xml
if (savedInstanceState == null) {
getSupportFragmentManager().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;
}
}