Android: Refresh ListView using ListAdapter and SimpleCursorAdapter?

I'm able to get the ListView to refresh by creating a new adapter and calling setListAdapter again.

I'm able to get the ListView to refresh by creating a new adapter and calling setListAdapter again. I named it adapter2 in the other method. TCursor = db.updateQuery(); ListAdapter adapter2=new SimpleCursorAdapter(this, R.layout.

Row, tCursor, columns, new int {R.id. Rowid, R.id. Date}); setListAdapter(adapter2); I'm not sure why this is necessary, but it works for now.

If anyone has a better solution, I'm willing to try it.

Solved my problem too. I can use this in AsynTask as well. – khr2003 Sep 16 at 22:46.

The method notifyDataSetChanged comes from the SimpleCursorAdapter parent class BaseAdapter. The parent implements ListAdapter and you should be able to pass it to your ListView. Try: tCursor = db.getAllEntries(); BaseAdapter adapter=new SimpleCursorAdapter(this, R.layout.

Row, tCursor, new String columns, new int {R.id. Rowid, R.id. Date}); setListAdapter(adapter); Then you should be able to use notifyDataSetChanged.

I changed the type of adapter from ListAdapter to BaseAdapter as you suggested. The list still loads properly, but calling adapter. NotifyDataSetChanged() doesn't refresh the ListView when I call it from another method.Am I using this incorrectly?

– spryan Feb 25 at 5:20.

In that case I recommend to go with custom Adapter, by extending the BaseAdapter class.

As I mentioned in the original question, notifyDataSetChanged() does not work for a ListAdapter. The error given by Eclipse says "The method notifyDataSetChanged() is undefined for the type ListAdapter". – spryan Feb 25 at 4:00 Rewriting code that works is hopefully a last resort, but I'll take that into consideration.

Thanks for trying. – spryan Feb 25 at 4:31.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions