Search code examples
javaandroidlistviewandroid-arrayadapterandroid-adapter

Updating an item of ListView from another Activity


I'm creating a ListView in Activity A which contains some kind of Post views, each of them have its own like button. Every post can be viewed in Activity B as a single post (Which I re-read from server because there's more info to present).

I'm trying to figure a way that if a user click the like button on Activity B (Which updates the server & UI of its own Activity (B)), would update the UI of the same post (which I have its ID and position in the list ofcourse) on Activity A. .

Any thoughts?


Solution

  • You have to update your adapter data for ListView in another activity and once you back to Activity A in onResume() you can call notifyDatasetChanged() to your adapter and refresh your ListView with newly updated data.