Converting An Activity To A Fragment
Why Stack Overflow recommends it
Stack Overflow users link it when they need a concrete walkthrough of turning an Android Activity into a Fragment.
Recommended by 2 people across 2 different months, 2013 to 2015.
What it is
A screencast by Andrew Ruffolo from 2012 that walks through converting an existing Android Activity from a published app into a Fragment and hosting that Fragment inside another Activity. It is aimed at adapting a phone app to make use of tablet screen space.
What people said
Recommends mike.b93 · 2013-04 · Stack Overflow · on “Activity cannot be cast to android.support.v4.app.Fragment”
After a while i was able to solve everything by adding a switch case statement here: @Override public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a DummySectionFragment (defined as a static inner class // below) with the page number as its lone argument. Fragment fragment; switch (position) { case 0: fragment = new StatisticsFragment(); break; case 1: fragment = new MainActivityFragment(); break; case 2: fragment = new DbListViewFragment(); break; default: fragment = new DummySectionFragment(); break; } return fragment; } and I made a copy of my activities and converted those to fragments like explained on this video: Conver
Recommends Parnit · 2014-03 · Stack Overflow · on “extends Activity with Fragment in Android”
Is there a certain type of information you looking for? I looked at the android developer site for information on fragments when i first started with them: [LINK] or [LINK] maybe this video can help as well [this video]
Cites Chimi · 2013-03 · Stack Overflow · on “Having Issues with an AsyncTask in a Fragment”
I'm in the process of trying to convert my code to work with fragments. I'm pretty new to Android, and I initially started out by making a lot of classes and just changing from one Activity to another Activity using intents. I am taking one of my classes that reads a JSON Array from a server and presents the table as a list and trying to convert it to a fragment. To do so, I've followed the tutorial that is presented here: [this video] which says I should change my onCreate to an onStart and include an onCreateView, which I have done. I also changed "ClassName.this" to "getActivity()" where it appeared. The code worked fine before trying to convert it to a fragment, but I am having issues now tha
Cites Hotcaribbean · 2015-01 · Stack Overflow · on “How to make a child in a listview open a fragment”
How can i navigate to one of my other fragments when i click on a child in my listview. Below is my class. /** * Pieced together from: * [LINK] * [this video] */ public class TodoFragment extends Fragment { public TodoFragment(){} ExpandableListAdapter listAdapter; ExpandableListView elv; List<String> listDataHeader; HashMap<String, List<String>> listDataChild; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){ return inflater.inflate(R.layout.fragment_todo,container, false); } @Override public void onStart() { super.onStart(); // get the listview elv = (ExpandableListView) getView().findViewById(R.id.lvExp); // preparing list data prepare