Problems:
The most common method for operating the elements in the "select all" list is to traverse and select all the checkboxes. However, this bug is, after the selection, when pulling down, the following are not selected. When pulling up, the above will be canceled. So, find a new solution, write it down, and save it for future use.
Solution
We use an array or set for the selected position to remember the selected status.
If this item is included in the Set, set their checkbox to the selected status.
We use the set, because the Set set can be repeated.
For example:
// 1. Create a set Private Hashset <string> itemselected = New Hashset <string> (); // 2. All selected click events Public Void Onclick (view v ){ Int Id =V. GETID (); Switch (ID ){ Case R. Id. bt_new_msg: intent = New Intent (conversationactivity. This , Newmessageactivity. Class ); Startactivity (intent ); Break ; Case R. Id. bt_all_selected: // Adds the selected status to a set For ( Int I = 0; I <Adapter. getcount (); I ++ ) {Cursor = (Cursor) Adapter. getitem (I); string idstr = Cursor. getstring (id_column_index); itemselected. Add (idstr);} Adapter. yydatasetchanged (); Break ; Case R. Id. bt_cancel_selected: Break ; }} 3. determine the elements in the Set set in the display mode, and set the checkbox selection status. // Set checkbook according to mode Mode If (Mode = Displaymode. Edit) {checkbox. setvisibility (view. Visible ); // Check whether the checkbox is selected If (Itemselected. Contains (idstr )){ // Selected Checkbox. setchecked (True );} Else { // Not selected Checkbox. setchecked ( False );}} Else {Checkbox. setvisibility (view. Gone );}