I'm creating a new Android Project
in Eclipse
and I'm only using SDK version 19 (Android 4.4). I did the same thing a few weeks ago but today I noticed a difference. There is an automatiacally generated inner class in my MainActivity
:
/**
* 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;
}
}
I've been trying to find documentation on this but I can't find anything. Is there a reason for this? Following guidelines should everything be a Fragment
now?
According to the Android documentation, a fragment is a part of applications user interface that is bound to an activity. Fragments have their lifecycle and layouts or UI components. Fragments help enrich your UI design, pass data between different screens, and adapt to different device configurations.
There are 12 lifecycle methods for fragment.
Yes creating new android project now creates appcompat version 7 lib with it. And activities are changed to activities containing fragment . From now on ui is to be handeled from Placeholder fragment. This new imrovement has an advantage as it supports action bar for older versions for 7.
It looks like they are wanting people to use Fragments for the content view of the activities now instead of setting it to the activity itself. They are trying to set forth a standard pattern.
This is fine by me, as I already use fragments this way :), though not as an inner class. That just gets messy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With