Fix for sliding loss selected when ListView contains checkbox in Android
Source: Internet
Author: User
<span id="Label3"><p>There are many ways to save a state, and one way I recommend it</p><p>Each entry in the ListView you typically write data with an entity class</p><p>Add a piece to your entity class</p><p></p><pre name="code" class="java">public Boolean ischecked = false;</pre><br>Then the adapter writes<p></p><p></p><pre name="code" class="java">Final mentity entity = (mentity) GetItem (position); holder.checkBox.setOnCheckedChangeListener (new Oncheckedchangelistener () {@Overridepublic void oncheckedchanged (compoundbutton buttonview, boolean isChecked) { entity.ischecked = ischecked;}}); Holder.checkBox.setChecked (entity.ischecked);</pre><br><span style="color:#FF0000">Note holder.checkBox.setChecked (entity.ischecked); Be sure to put it behind the Listener.</span><p></p><p>Here is the state saved to the object of your entity class, in fact, the development of the project should be understood.<br></p><p style="font-size:12px;">Copyright Notice: This article for Bo Master original article, without Bo Master permission not Reproduced.</p><p>Fix for sliding loss selected when ListView contains checkbox in Android</p></span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service