开发者

Android attach new data without smashing the old one with an adapter

My problem is the next:

i have one way to bind data <-> View that is ... using an adapter, that simply inflates one specific layoyt and binds the column names to a ids in layout for each row in cursor (database cursor), this is whats th开发者_如何学Goe job of the adapter.

I have at time one listview with data (binded with this adapter) than used one cursor to get all items

But i add a new item, and i goes back to my old view and now the oldview must contain the new item, and i, the developer what i do is:

i go to db get the last one id. if the last one id is greater than the lastone in listview i return a cursor that contains the next elements, and now i wanna bind to the listview WITHOUT smashing the old values, but just adding using the same adapter to have a common way to bind the data to my view?

It is possible?


If i'm right, all you need is to call adapter.notifyDataSetChanged() instead of retrieving and adding new data from db manually. Or even use this method of Activity instead to simplify.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜