Uncheck all Check boxes in Android -


i have clear button in layout on click of want uncheck checkboxes inside linear layout listview .

xml

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical">      <linearlayout         android:id ="@+id/mainlayout"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:orientation="vertical">          <linearlayout             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:orientation="horizontal">              <button                 android:id="@+id/btnclear"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_gravity="right|center"                 android:gravity="right|center"                 android:text="remove" />         </linearlayout>          <linearlayout             android:layout_width="match_parent"             android:layout_height="match_parent"             android:orientation="horizontal">             <listview                 android:id="@+id/listview"                 android:layout_width="0dp"                 android:layout_height="match_parent"                 android:layout_weight="5"                 android:cachecolorhint="@android:color/transparent"                 android:divider="#fff"                 android:dividerheight="1dp"                 android:fadingedge="none">             </listview>         </linearlayout>     </linearlayout> </linearlayout> 

inside listview inflating layout have checkbox.now btnclear want uncheck checkboxes .how can please me in this

create loop going through child items of listview , check if view of type checkbox , perform setchecked(false) on same.

for (int = 0; < mlistview.getcount(); i++) {         view mchild = mlistview.getchildat(i);         //replace r.id.checkbox id of checkbox in layout        checkbox mcheckbox = (checkbox) mchild.findviewbyid(r.id.checkbox);        mcheckbox.setchecked(false); } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -