I am trying to write a program to display a set of values from a database on my android. Using php connection.
My question is
ListAdapter la = new ListAdapter(this, R.id.Menu);
or
listView.setAdapter(new ListAdapter(this, R.id.Menu, menuitems));
both codes give me the same error. Cannot instantiate the type ListAdapter.
My relevant imports are :
- android.widget.AdapterView
- android.widget.ListAdapter
- android.widget.ListView import
- android.widget.AdapterView.OnItemClickListener import
- android.widget.ArrayAdapter
why is this happening ? Why I can’t instantiate the required object ? What am I doing wrong ?
please help
Thank you in advance!
ListAdapteris an interface. In Java, you need to instantiate a concrete class. A concrete class serves as a bridge between the ListView and the data to be displayed; it is responsible (among other things) for packaging up the data as a row View for the ListView to use. Pick the concrete class that corresponds to how your data is organized. (It might be anArrayAdapter<YourDataType>, aCursorAdapter, another of the classes listed in the docs, or even something of your own design.)