简体   繁体   English

从另一个Activity更新ListView的项目

[英]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.

相关问题 Android-从另一个活动将项目添加到ListView - Android - Adding item to ListView from another Activity 无法在另一个活动上显示listView中的项目 - Unable to display item from listView on another activity 从另一个活动中单击按钮后,从活动中删除列表视图项 - Delete a listview item from activity on button click from another activity 将项目从另一个活动添加到列表视图(仅添加一个项目) - Add item to listview from another activity (it only adds one item) 添加新的ListView项目并从另一个活动中获取项目的价值 - Adding new ListView item and get value of item from another activity 当我从另一个活动获得结果时,ListView仅更新一个视图项,如何获得所有过去的结果? - ListView is updating only one view item when I get the results from another activity, how do I get all the past results? 通过数据库从另一个活动中的列表视图中删除项目 - delete an item from listview from another activity through database 将数据从listview中的单击项传递到另一个活动时出错 - Error while passing data from clicked item in listview to another activity Android-从另一个活动onButtonClick向ListView添加项目 - Android- Adding item to ListView from another activity onButtonClick 单击ListView项时将_id从一个活动传递到另一个活动 - Passing an _id from one activity to another when ListView item is clicked
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM