Disable EditText in ListView when CheckBox is unchecked Android
<p>I have a custom <code>ListView</code> containing a <code>CheckBox</code> and an <code>EditText</code>. I want the <code>EditText</code> to be clickable and editable only if <code>CheckBox</code> is checked. How to implement that? I tried using :</p>

<pre><code>public class ScrapListAdapter  extends ArrayAdapter {
    ArrayList&lt;ScrapOffer&gt; arrayScrapItems;
    Context context;

    public ScrapListAdapter(Context context, ArrayList&lt;ScrapOffer&gt; arrayScrapItems) {
        super(context, R.layout.scrap_list_row_item, arrayScrapItems);
        // TODO Auto-generated constructor stub
        this.context = context;
        this.arrayScrapItems = arrayScrapItems;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        LayoutInflater inflater = ((Activity) context).getLayoutInflater();
        convertView = inflater.inflate(R.layout.scrap_list_row_item, parent, false);
        final EditText kg = (EditText) convertView.findViewById(R.id.editText1);
        final CheckBox cb = (CheckBox) convertView.findViewById(R.id.checkBox1);
        final TextView txtKg = (TextView) convertView.findViewById(R.id.textView1);
        final float scale = context.getResources().getDisplayMetrics().density;
        cb.setPadding(cb.getPaddingLeft() + (int)(10.0f * scale + 0.5f),
                cb.getPaddingTop(),
                cb.getPaddingRight(),
                cb.getPaddingBottom());
        //cb.setText(modelItems[position].getName());
        cb.setText(arrayScrapItems.get(position).getItemName());

        cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

               @Override
               public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {
                   if(isChecked)
                   {
                      // Toast.makeText(context, "You checked " + arrayScrapItems.get(position).getItemName(), Toast.LENGTH_SHORT).show();
                       cb.setButtonDrawable(R.drawable.checkbox_background_active);
                       cb.setTag(arrayScrapItems.get(position).getItemId());
                       kg.setBackgroundResource((R.drawable.kg_box));
                       txtKg.setTextColor(Color.parseColor("#000000"));
                       kg.setFocusable(true);
                       kg.setEnabled(true);
                       kg.setInputType(InputType.TYPE_CLASS_NUMBER);
                   }
                   else
                   {
                       //Toast.makeText(context, "You unchecked " + arrayScrapItems.get(position).getItemName(), Toast.LENGTH_SHORT).show();
                       cb.setButtonDrawable(R.drawable.checkbox_background);
                       kg.setBackgroundResource((R.drawable.kg_box_inactive));
                       cb.setTag("");
                       txtKg.setTextColor(Color.parseColor("#D3D3D3"));
                       kg.setFocusable(false);
                       kg.setEnabled(false);
                       kg.setInputType(InputType.TYPE_NULL);
                   }
               }
           }
        ); 


        return convertView;
    }
}
</code></pre>

<p>But this isn't working.</p>

<p>scrap_list_row_item.xml :</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" &gt;

    &lt;LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="10dp"
        android:orientation="horizontal" &gt;

        &lt;CheckBox
            android:id="@+id/checkBox1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0.4"
            android:button="@drawable/checkbox_background"
            android:text="item"
            android:paddingRight="10dp"
            android:textColor="#000000"
            android:textSize="13dp" /&gt;

        &lt;EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@drawable/kg_box_inactive"
            android:ems="10"
            android:paddingLeft="5dp"
            android:textSize="10dp"
            android:inputType="number" /&gt;

        &lt;TextView
            android:id="@+id/textView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_weight="1"
            android:text="kg"
            android:textSize="13dp"
            android:textColor="#D3D3D3" /&gt;
    &lt;/LinearLayout&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p>Any help will be greatly appreciated.</p>