當我們從一個頁面調到另一個頁面的時候,需要把該頁面的一些設定值也傳遞給下一個頁面。當要傳遞的值很多時,我們可以傳遞一個對象。
頁面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化的類。
