I'm creating an app which uses a Data Access Object class to load values into a Serializable object.
开发者_StackOverflow社区How do I do the following.
- Find the ListView object from the layout.
- Load the serialized list into the ListView
i'm reading the following doc http://developer.android.com/resources/tutorials/views/hello-listview.html
but i'm getting this error when i'm trying to follow that code but using the serialized list:
cannot find symbol
[javac] symbol : constructor ArrayAdapter(
i have this at the top of my file too
import android.widget.ArrayAdapter;
I'm trying to target 2.1 and above.
this is my code as it stands
http://pastie.org/1976415
You should use a ArrayAdapter when show data from a database in a ListView. Use a CursorAdapter (e.g. SimpleCursorAdapter) instead. With a cursor and a CursorAdapter you will get much better performance as items get only read from the database when they are needed (e.g. the user scrolls the list).
When you use an ArrayAdapter you have do load all items in advance which is unnecessary as you might not need all of them. So using a Cursor and a CursorAdapter will give you better performance and reduce the memory usage.
Check this blog post for a tutorial.
You're passing a list of Ticket
s to the <String>
adapter. Try to change it:
setListAdapter(new ArrayAdapter<Ticket>(this, R.layout.main.list, tickets));
精彩评论