user5645695
user5645695

Reputation:

List Activity in a Fragment

A list activity class extends ListActivity for creating list menu. As java doesn't allow multiple inheritance and a fragment class already extends Fragment than how can i make a list menu in a fragment? or there is an alternative method for doing so?
Thanks in advance.

Upvotes: 1

Views: 2300

Answers (4)

Ruag
Ruag

Reputation: 189

You simply add a listView in your fragment layout file and use it in your fragment class. the method you are using is quite old.

Upvotes: 0

frogatto
frogatto

Reputation: 29285

Alternative to ListFragment, you can create your own ListView within an empty Fragment.

Tutorial: Create a simple ListView.

Upvotes: 0

Viral Patel
Viral Patel

Reputation: 33398

You should use ListFragment instead of Fragment

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.

Here is a simple tutorial to show how it is used.

Upvotes: 0

ngoctranfire
ngoctranfire

Reputation: 793

I believe you can just use an activity and use a ListFragment and in onActivityCreated(Bundle b), just do the following: setHasOptionsMenu(true). Maybe I'm not understanding your question otherwise... No need for that multiple inheritance complication.

Upvotes: 1

Related Questions