[英]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. 我正在活动A中创建一个ListView,其中包含某种Post视图,每个视图都有自己的喜欢按钮。 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). 每个帖子都可以在活动B中作为单个帖子查看(我要从服务器重新阅读,因为有更多信息需要呈现)。
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. . 我正在尝试一种方法,如果用户单击活动B上的“赞”按钮(将更新其自己的活动(B)的服务器和用户界面),则会更新同一帖子的用户界面(我具有其ID和在课程列表中的位置)。
Any thoughts? 有什么想法吗?
您必须在另一个活动中更新ListView的适配器数据 ,并且一旦在onResume()
返回到Activity A
,就可以调用notifyDatasetChanged()
到适配器,并使用新更新的数据刷新ListView
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.