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

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.

To learn how to create a custom list in Sketchware visit:
http://www.sketchwarehelp.com/2017/10/custom-dialog-box-in-sketchware-using.html?m=1

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 onBindCustomView event, when Checkbox is clicked, set value of File shared preference as per the checked state of the CheckBox.
4. The code in onBindCustomView​ may look as in image below.

5. That is all. Save and run the project,

Komentar

Cara pembuatan Apps paling Populer

Create Stopwatch App in Android using Sketchware

TextInputLayout in Sketchware

How to find and​ highlight a word in a text field in Sketchware?

A Flash Light App in Sketchware

How to enable download in webview in Sketchware apps?

Intent - Open File By Type

Code for implementing Notifications in Sketchware

How to share an image from Drawable folder?

ActionBar back button

Animation Transtition Animation