【问题标题】:Android how to pass set values to another activity? [duplicate]Android如何将设置值传递给另一个活动? [复制]
【发布时间】:2016-02-03 10:13:51
【问题描述】:

Android 中,我想将设置值传递给另一个activity..我该怎么做?

        Set<Person> persons=getPersons();

        Intent intent = new Intent(getApplicationContext(), MainActivity2.class);
        intent.putExtra("persons", persons);  //Here I am getting error

        startActivity(intent);

但我在intent.putExtra()..为什么出错?如何传递这些设置值?

【问题讨论】:

  • 分享您的班级人员代码。
  • 你需要使用paracable
  • persons 是一个集合类型,它会询问原始数据类型
  • 使用HashSet 而不是Set

标签: android


【解决方案1】:

你需要在 Person 类中使用实现 parcable

例如

public class Person implements Paracable{


}

【讨论】:

    猜你喜欢
    • 2011-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多