Jun 10, 2008

(Android) Is this a problem of BaseAdapter?

I created a object of ListView and my own LinearLayout for each row. The first row contains each column's name, so when i refresh this ListView, the first row don't change, so i pass the first row's value to a variable, and use clear() to remove all my ListView's element, and then add the variable in the ListView. I thought what i should do is create new LinearLayout and add them in ListView, with notifyDataSetChanged() method the ListView should be refreshed.

A problem comes, in the "refreshed" ListView there isn't new values, the values displayed are the first row which contains all column's name and the first row of value which should be deleted by the below clear().

I checked the list in the adapter of ListView, all the new values didn't added in the adapter's list. I can't figure out what is going on here.

The solution i found right now is after clear all the items, create a new adapter like adapter = new MyAdapter(this), and don't forget reset this adapter in the ListView.

No comments: