开发者

Android: refreshing list view from different activity

I have ListActivity with CustomArrayAdapter. My extension of ArrayAdapter allows me to do add/remove operations with the rows. It works fine...inside ListActivity. But then I need to add/edit rows in my list from different Act开发者_开发问答ivity and troubles begin. How can I do that? All I need inside my EditActivity is CustomArrayAdapter object. I made it static and tried. It worked, but is it a right thing? Thanks for the answers, masters!


What comes in my mind:

  • One way could be to make your objects in the ArrayList serializable you could pass then the actual list to the next activity via intent and use it there for the adapter.
  • Other way would be: if you know the ID of the element which you want to delete, pass it as intent, delete it from the ArrayList and set adapter.notifyDataSetChanged();

I don't think to have a static ArrayAdapter class is the right way. This means you affect both activities at the same time. Because none of them have an own object.

Hope this helps

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜