It is easier to create an array to maintain the status of checkBox. When CheckBox receives a click event, change the status of the corresponding checkBox in statusList, and at the same time set the status of checkBox according to the value of statusList in the onBindView/getView method.
---------------------Separating line------------------------- -------------------------------------------------- ------ I didn’t see that it requires single selection. . For single selection, you need to add a flag to record the last selected position, then get the object from the adapter, and modify the checkStatus if it is visible.
You can write like this with minimal changes to your code. First find the address selected by default
Two situations:
After selecting another address and then canceling it, the default address will be re-selected
Once you select another address, the default option will no longer work
It is easier to create an array to maintain the status of checkBox.
When CheckBox receives a click event, change the status of the corresponding checkBox in statusList, and at the same time set the status of checkBox according to the value of statusList in the onBindView/getView method.
---------------------Separating line------------------------- -------------------------------------------------- ------
I didn’t see that it requires single selection. . For single selection, you need to add a flag to record the last selected position, then get the object from the adapter, and modify the checkStatus if it is visible.