zoukankan      html  css  js  c++  java
  • Android 如何进行页面传递对象

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

       页面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化的类。
    高山流水,海纳百川!
  • 相关阅读:
    [机房测试]11.11
    题解——[AHOI2013]作业(莫队)
    [机房测试]11.7
    [机房测试]11.6
    [机房测试]11.5
    [机房测试]11.4
    [机房测试]10.29
    [机房测试]10.28
    初学SPFA
    神奇的游戏
  • 原文地址:https://www.cnblogs.com/ahcc08/p/6666530.html
Copyright © 2011-2022 走看看