【发布时间】:2015-10-02 11:02:01
【问题描述】:
我有一个包含字符串列表的集合:
public Set<String> favs = new HashSet<>();
但是,当我开始另一个活动“收藏夹”时,我想将此列表传递给我的“收藏夹”课程,目前我有:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
} else if (id == R.id.exit_the_app) {
finish();
return true;
} else if (id == R.id.favorites) {
Intent startfavs = (new Intent(Insulter.this, Favorites.class));
startActivity(startfavs);
return true;
}
return super.onOptionsItemSelected(item);
}
我想在“收藏夹”中传递这个集合,并在将其更改为列表后最终将其显示在列表视图中。这样做的最佳方法是什么?
(注意:我的第二个活动都设置在歧管中并且运行良好)
【问题讨论】:
-
你将不得不使用intent和intent extra。我建议你更多地了解他们here。
-
将它作为可序列化的捆绑包传递给活动