Creating a three states checkbox on android

前端 未结 3 437
独厮守ぢ
独厮守ぢ 2020-12-31 02:18

I\'m stuck in front of a big problem: I\'d like to make three state checkbox on android. It\'s a checkbox upon a ListView with checkboxes. It should allows user to switch be

3条回答
  •  独厮守ぢ
    2020-12-31 02:45

    If you really insist on using a CheckBox where each element have 3 states then the following might work but I haven't tried it: - Make a class that extends the CheckBox class. - Add a variable : "checkstate" of type int or byte. The class should have a Boolean "isChecked" variable. - Override the onClick or onCheck method so that it change the checkstate variable between the 3 states instead of toggling the isChecked variable. - Upon display, check the "checkstate" and do some visual effect to show the 3rd state. - Finally, tell me if it works.

提交回复
热议问题