How to converting an activity into a fragment.
FooActivity.java -> FooFragment.java
{CODE()}extends Activity -> extends Fragment{CODE}
{CODE(wrap="0")}protected void onCreate(Bundle savedInstanceState) -> public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState){CODE}
{CODE(wrap="0")}setContentView(R.layout.activity_bugs) -> View view = inflater.inflate(R.layout.activity_bugs, container,false); return view;{CODE}
{CODE()}setHasOptionsMenu(true);{CODE} If you do not add this, the overriden methods will not be called.
The fragment version includes inflator and does not return a value.
{CODE()}public boolean onCreateOptionsMenu(Menu menu) ->
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); }{CODE}
finish() needs to be called via getActivity()
findViewById() needs to be called via the view created in onCreateView()
getBaseContext() needs to be replaced by getActivity()
Create a new FragmentActivity using the fragment