当我们从一个页面调到另一个页面的时候,需要把该页面的一些设定值也传递给下一个页面。当要传递的值很多时,我们可以传递一个对象。

   页面1:

Intent intent = new Intent(PageOneActivity.this, PageTwoActivity.class);
SoftwareProlemInfo info = softwareProlemInfos.get(position);

Bundle bundle = new Bundle();
bundle.putSerializable("softPro", info);
intent.putExtras(bundle);
startActivity(intent);

 页面2:

 SoftwareProlemInfo softwareProlemInfo;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pagetwo);

        Intent intent  = this.getIntent();
        softwareProlemInfo = (SoftwareProlemInfo)intent.getSerializableExtra("softPro");
     ....
}
其中:SoftwareProlemInfo是一个Serializable化的类。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-28
  • 2022-12-23
  • 2021-08-01
猜你喜欢
  • 2022-12-23
  • 2022-02-09
  • 2021-05-10
  • 2022-12-23
  • 2021-09-10
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案