Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call the setListAdapter in android

I have a class not extend from ListActivity, so how can I replace this code without error?

SimpleCursorAdapter adapter = new SimpleCursorAdapter(
  this,
  R.layout.sbooks_row,
  cursor, from,
  to
);
setListAdapter(adapter);
like image 336
Dennie Avatar asked Aug 10 '09 10:08

Dennie


People also ask

What is ListActivity in android?

An activity 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. ListActivity hosts a ListView object that can be bound to different data sources, typically either an array or a Cursor holding query results.


1 Answers

ListView myList=(ListView)findViewById(android.R.id.list);

myList.setAdapter(adapter);
like image 74
CommonsWare Avatar answered Oct 07 '22 11:10

CommonsWare