Android - Add an item from one ListView to another ListView?

浪子不回头ぞ 提交于 2019-12-24 13:26:29

问题


I have an app that shows news from a RSS feed. There is ListView-1 which loads the news and when you click on an item(news), it shows only the selected news in a seperated xml layout. On the ActionBar for the single news item layout, user can click on Add to Favourites.

I have another activity and layout file and a listview just for Favourites. How can I copy an item from one listview to another?

So, the user can add news from main ListView-1 to another list called ListView-2.

I cannot use intents for sending one list item. I have been thinking of using SharedPreferences to share an ArrayList, but something else needs to be the solution.


回答1:


You don't need intents, just separate view and data, keep news in the singleton class, for example NewsManager, and keep one list for all news, one for favourite news, and use favourite list in the ListView2 adapter



来源:https://stackoverflow.com/questions/24096836/android-add-an-item-from-one-listview-to-another-listview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!