private String a = "";
private String b = "";

新建一个类 MyClass。实现接口 Parcelable 。实现所有方法

属性getter 和setter  ,实现所有属性的构造方法

public MyClassA(String a, String b) {
    this.a = a;
    this.b = b;
}


在activity中通过Parcelable传递数据


在activity中通过Parcelable传递数据



MainActivity 就和正常在activity中通过Parcelable传递数据的intent的跳转一样

MyClassA myClassA = new MyClassA("a", "b");
Intent intent = new Intent(this, ParcelableActivity.class);
Bundle bundle = new Bundle();
bundle.putParcelable("key", myClassA);
intent.putExtras(bundle);
startActivity(intent);

AnotherActivity 接受数据

getIntent().getParcelableExtra("key");

--------------------------------------------------------------------------------------------------------------------------------


相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-15
  • 2022-12-23
  • 2022-12-23
  • 2021-08-25
猜你喜欢
  • 2021-06-24
  • 2021-12-05
  • 2022-12-23
  • 2021-09-11
  • 2021-09-09
  • 2021-09-27
  • 2021-06-25
相关资源
相似解决方案