Skip to main content

Posts

Showing posts from September, 2017

Using a list fragment with cursor adapter

All these days, I avoided using fragments. But then I realized for my this particular applications fragments are ideal. I have a master - detail list in my app. Let us say you want to have two fragments - one is a fragment which contains a list of elements and second one expands one element of the list. Both of them share the same cursor from the activity. Let us start with list fragment. Do not try creating list fragment using a wizard. It unnecearrily adds too many methods and classes. Let us start writing our own fragment like this class MyListFragment extends ListFragment { } Next using code menu override option, override the following method onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) This method should be used for inflating the layout file for the fragment.  I have a framelayout in parent activity of this fragment with the id as container. So I will specify that for inflating. The framelayout will be the parent vi