Showing posts from April, 2013

ListFragments in Android with simple example

A Fragment represents a behavior of user interface in an Activity. A activity can have more than one fragments and also a fragment can be used in more than one activities. You can use Fragment instead of Activity , TabActivity, ListActivity etc.,

Why Fragments?

            TabActivity was deprecated in API Level 13 Because it is a subclass of ActivityGroup And ActivityGroup was deprecated because of slow performance. You can use the Fragment and FragmentManager APIs instead. When compared to activity the Fragment is much faster.

            This post is an example of ListFragment in android. A Fragment that displays a list of items by binding to a data source such as an array or Cursor, and exposes event handlers when the user selects an item.

            ListFragment hosts a listview object that can be bound to different data sources, typically either an array or a Cursor holding query results.

The following program creates a ListFragment.

package co…