Java – onclicklistener (Android studio) in the check box
•
Java
This is part of my code, including Check@R_521_2419 @( Chck@R_521_2419 @No):
final Check@R_521_2419@ Chck@R_521_2419@No = (Check@R_521_2419@)promptsView.findViewById(R.id.Chk@R_521_2419@No); Chck@R_521_2419@No.setChecked(true); Chck@R_521_2419@No.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (Chck@R_521_2419@No.isChecked()) { Chck@R_521_2419@No.setChecked(false); } else if (!Chck@R_521_2419@No.isChecked()) { Chck@R_521_2419@No.setChecked(true); } } });
At the beginning, I set true for the ischecked () method on the check box, and then implemented onclicklistener. Com on the check box When I run the application, the check box is checked because I have defined an eraser, but when I click the check box, it is deselected, and then unnecessary checks are performed again (I didn't check the check box again!) What can I do to solve this problem? What's wrong with my code? thank you!
Solution
Check@R_521_2419 @The "check" process is handled automatically – you do not have to manage standard usage yourself
View this example from the document Here, when click events are captured, they are operating based on the ischecked () state
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码