make header select all inside the alertdialog.builder for select and unselect all checkbox
<p>I want to create one header inside the <strong><code>alertdialog.builder</code></strong> and condition is if i  check this checkbox it will select all checkboxes in the list and if i uncheck it then it will uncheck all checkboxes.<br> Please help me.....
Thanks:-</p>

<pre><code>AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setAdapter(new CategoryAdapter(getApplicationContext(),R.layout.categorylist,R.id.xTvCategoryName, mAlCategoryNames, Home.this, getLayoutInflater()), null);
builder.setTitle("CHOOSE CATEGORIES");

builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {
        Log.w("Cancel",""+"Called");
        Set&lt;SavingCheckBoxState&gt; keys=CategoryAdapter.mCheckMaps.keySet();
        //checkAll(false);
        // selected[which] = false;
        ((AlertDialog) dialog).getListView().setItemChecked(which, false);
        ListView list =((AlertDialog) dialog).getListView();
        int size = list.getCount();
    }
});

builder.setPositiveButton("Add", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {
        mAlFilterCategory.clear();
        Set&lt;SavingCheckBoxState&gt; keys = CategoryAdapter.mCheckMaps.keySet();
        mAlFilterCategory = new ArrayList&lt;String&gt;();
        if (keys.size() &gt; 0) {
            Iterator&lt;SavingCheckBoxState&gt; it = keys.iterator();
            mCategory_Name=it.toString();
            while (it.hasNext()) {
                SavingCheckBoxState data = it.next();
                if (data.isSelected()) {
                    Log.w("category name", data.getmCatgegoryName());
                    mAlFilterCategory.add(data.getmCatgegoryName());
                }
            }
        }
    }
});

builder.show();
</code></pre>
