Log.d(TAG, "onChanged: " + loggedUserAuthResource.data.getUserPhotos());
List<UserPhoto> copiedList = loggedUserAuthResource.data.getUserPhotos();
copiedList.add(new UserPhoto("ADD"));
Log.d(TAG, "onChanged: " + copiedList);
Log.d(TAG, "onChanged: " + loggedUserAuthResource.data.getUserPhotos());
如您所见,我只想将一个项目添加到我复制的列表中,但它也会添加到 loggedUserAuthResource 列表中。
2019-08-18 15:06:18.104 8151-8151/ D/EditProfileActivity: onChanged: [UserPhoto{photoName='110ab4146695a093834701640fcee83c_y.jpg', orderId=1}, UserPhoto{photoName='59b7ee6ad3107d83227d017c45ffc899_y.jpg', orderId=2}, UserPhoto{photoName='90ae37db9a5d44026ebad8f622bf2c59_y.jpg', orderId=3}, UserPhoto{photoName='d2f7968640ebb4260b5e5dd1a10c1efd_y.jpg', orderId=4}, UserPhoto{photoName='e792f85d4f53a777f4399fe79f8edd99_y.jpg', orderId=5}, UserPhoto{photoName='22f943f0507223ce31fa1ca3c0e61b32_y.jpg', orderId=6}, UserPhoto{photoName='8b19b52c1482c522be21151eb4eb8009_y.jpg', orderId=7}]
2019-08-18 15:06:18.104 8151-8151/ D/EditProfileActivity: onChanged: [UserPhoto{photoName='110ab4146695a093834701640fcee83c_y.jpg', orderId=1}, UserPhoto{photoName='59b7ee6ad3107d83227d017c45ffc899_y.jpg', orderId=2}, UserPhoto{photoName='90ae37db9a5d44026ebad8f622bf2c59_y.jpg', orderId=3}, UserPhoto{photoName='d2f7968640ebb4260b5e5dd1a10c1efd_y.jpg', orderId=4}, UserPhoto{photoName='e792f85d4f53a777f4399fe79f8edd99_y.jpg', orderId=5}, UserPhoto{photoName='22f943f0507223ce31fa1ca3c0e61b32_y.jpg', orderId=6}, UserPhoto{photoName='8b19b52c1482c522be21151eb4eb8009_y.jpg', orderId=7}, UserPhoto{photoName='ADD', orderId=0}]
为什么会这样?我怎么能阻止它?
慕工程0101907
30秒到达战场
红糖糍粑
相关分类