Posts

Showing posts with the label CheckBox in Custom ListView

How to prevent automatic checking of checkbox on scrolling in Custom ListView in Sketchware?

Image
In  Custom ListView , if you use Checkbox , you will notice that when you you check a few CheckBoxes in the ListView and scroll down you find more CheckBoxes already checked. The problem is same if you use switch in Custom ListView, or try to change color of selected items in custom ListView. The solution is to save the checked position in file: shared preferences , and onCustomBind , set the checked state of Checkbox as per the Saved state in file: shared preferences. Suppose you have a custom listview and you have used CheckBox in CustomView to create a list with multiple choice mode. If you select an item and scroll down you will see more automatically selected items. To prevent this follow the steps below. 1. Add file: shared preferences component to your sketchware project. 2. In onBindCustomView​ event , set checked state of CheckBox to true or false depending on the value of File key specific to position in list, as shown in image below. 3. Next, in onBindCu