简体   繁体   中英

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

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.

您不需要意图,只需将视图和数据分开,将新闻保留在单例类中(例如NewsManager),并为所有新闻保留一个列表,为最喜欢的新闻保留一个列表,并在ListView2适配器中使用最喜欢的列表

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM