可以通过以下步骤实现:
Intent intent = new Intent(ParentActivity.this, ChildActivity.class);
intent.putParcelableArrayListExtra("customList", customList);
startActivityForResult(intent, REQUEST_CODE);
ArrayList<CustomObject> customList = getIntent().getParcelableArrayListExtra("customList");
Intent intent = new Intent();
intent.putParcelableArrayListExtra("customList", customList);
setResult(RESULT_OK, intent);
finish();
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {
ArrayList<CustomObject> customList = data.getParcelableArrayListExtra("customList");
// 在父活动中使用修改后的ArrayList对象
}
}
通过以上步骤,就可以将自定义对象的ArrayList从子活动传回父活动,并在父活动中使用修改后的ArrayList对象。
领取专属 10元无门槛券
手把手带您无忧上云