title: Why CheckBox checked not working with Kotlin programmatically?
body: <p>I think this question may be asked before but this issue happened with me too so , I'm asking here again to see we can get some solution over it.</p>
  
  <p>So basically problem is making Checkbox checked Programmatically not working with Kotlin code . To explain , I'm sharing my code &amp; screenshot of problem.</p>
  
  <pre><code>     //filterContraints is ArrayList&lt;Integer&gt; type
  
       if(filterContraints!!.size &gt; 0){
  
          filterContraints!!.forEach {
  
          Log.d(TAG, "For each filter constraints : $it")
          if(it == AppConstants.MAC_OS &amp;&amp; !chkMacOS!!.isChecked)
          {
             chkMacOS!!.isChecked = true
          }
          if(it == AppConstants.WINDOWS_OS &amp;&amp; !chkWindows!!.isChecked)
          {
             chkWindows!!.isChecked = true
          }
          if(it == AppConstants.LINUX_OS &amp;&amp; !chkLinux!!.isChecked)
          {
             chkLinux!!.isChecked = true
          }
          if(it == AppConstants.ALL_OS &amp;&amp; !chkAllOs!!.isChecked)
          {
             chkAllOs!!.isChecked = true
          }
        }
     }
  </code></pre>
  
  <p>Here is xml of entire layout :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/bottom_sheet"
      android:layout_width="match_parent"
      android:layout_height="200dp"
      android:background="@android:color/white"
      android:clickable="true"
      android:clipToPadding="false"
      android:fitsSystemWindows="true"
      app:behavior_hideable="true"
      app:behavior_peekHeight="0dp"
      app:layout_behavior="@string/bottom_sheet_behavior"&gt;
  
      &lt;TextView
          android:id="@+id/txt_filter_title"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_gravity="center"
          android:gravity="center"
          android:textColor="@color/darkestGrey"
          android:layout_marginTop="@dimen/padd_10"
          android:text="@string/txt_filter_payload"
          android:fontFamily="sans-serif-medium"
          android:textStyle="bold"
          android:textSize="18sp" /&gt;
  
  
      &lt;LinearLayout
          android:id="@+id/row_filter_categories"
          android:layout_width="wrap_content"
          android:layout_below="@+id/txt_filter_title"
          android:layout_marginTop="@dimen/padd_10"
          android:layout_centerHorizontal="true"
          android:layout_height="wrap_content"
          android:orientation="horizontal"&gt;
  
          &lt;CheckBox
              android:id="@+id/chk_mac"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:textSize="15sp"
              android:text="@string/chk_os_mac" /&gt;
  
          &lt;CheckBox
              android:id="@+id/chk_windows"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginStart="@dimen/padd_10"
              android:layout_marginEnd="@dimen/padd_10"
              android:textSize="15sp"
              android:text="@string/chk_os_windows" /&gt;
  
          &lt;CheckBox
              android:id="@+id/chk_linux"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:textSize="15sp"
              android:text="@string/chk_os_linux" /&gt;
  
          &lt;CheckBox
              android:id="@+id/chk_all_os"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:textSize="15sp"
              android:textAllCaps="false"
              android:text="@string/chk_os_all" /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;Button
          android:id="@+id/btn_apply_filter"
          android:layout_width="wrap_content"
          android:layout_below="@+id/row_filter_categories"
          android:layout_marginTop="@dimen/activity_vertical_margin"
          android:layout_marginEnd="@dimen/padd_10"
          android:layout_alignParentEnd="true"
          android:gravity="center"
          android:background="@color/colorPrimary"
          android:textColor="@color/white"
          android:layout_height="wrap_content"
          android:textSize="15sp"
          android:text="@string/txt_apply_filter" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>And here is declarations part in Kotlin:</p>
  
  <pre><code>    private var chkMacOS: CheckBox? = null
      private var chkWindows: CheckBox? = null
      private var chkLinux: CheckBox? = null
      private var chkAllOs: CheckBox? = null
  </code></pre>
  
  <p>Here is retrieving part:</p>
  
  <pre><code>    chkMacOS = fragmentView.findViewById(R.id.chk_mac)
      chkWindows = fragmentView.findViewById(R.id.chk_windows)
      chkLinux = fragmentView.findViewById(R.id.chk_linux)
      chkAllOs = fragmentView.findViewById(R.id.chk_all_os)
  </code></pre>
  
  <p>And here is output: See last two checkbox , only border is coloured but not selected.</p>
  
  <p><a href="https://i.stack.imgur.com/A7Ehk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/A7Ehk.png" alt="enter image description here"></a></p>