Android的 - 从一个ListView控件添加一个项目到另一个的ListView? [英] Android - Add an item from one ListView to another ListView?

查看:391
本文介绍了Android的 - 从一个ListView控件添加一个项目到另一个的ListView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,显示了一个RSS源的消息。有ListView控件-1,它加载的消息,当你点击一个项目(新闻),它只显示了分离式XML布局所选择的消息。在动作条为单条新闻的布局,用户可以点击添加至收藏夹。

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?

因此​​,用户可以从主的ListView-1添加新闻到一个名为ListView控件-2另一份名单。

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

我不能使用意图发送一个列表项。
我一直在想使用共享preferences共享一个ArrayList的,但别的东西需要被解决。

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适配器使用收藏夹列表

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

这篇关于Android的 - 从一个ListView控件添加一个项目到另一个的ListView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆