- You could store the data in an
object
which is accessible from both Activities
- Before adding, check the size of the list. If it's already at the maximum size, don't add more.
- You can use a MutableList here (such as ArrayList) which has a
remove
function
- Before adding, check if any card in the list is equal to the card you wish to add. If so, don't add it again.
It really all does not have to be all that complicated, but a lot depends on how you represent for example a Card and a Deck in code. So sharing what you have is still a good idea.
Using an ArrayList instead of an Array should already solve some of your issues, as a List has a dynamic size compared to the fixed-size Array.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…