title: Getting tag of Multiple Checkbox from Custom Adapter binded on AlerDialog
body: <p>I have an <code>AlerDialog</code> which displays a <em>list of items</em> with <code>checkboxes</code>.I am trying to get the <code>tag (Checkbox.getTag())</code> of selected <code>checkboxes</code> and append them to a <code>String</code>. Then i want to get this <code>String</code> from the class where i have declared the <code>AlerDialog</code>. </p>
  
  <p><strong>Is there a way to do that, or i should change the logic of implemetation?</strong></p>
  
  <p>Here is my <code>CustomAdapter</code>:</p>
  
  <pre><code>    public class DepartmentsAdapter extends BaseAdapter {
  
      private Context mContext;
      private List&lt;DepartmentModel&gt; departmentsList;
  
      private LayoutInflater inflater;
  
      public DepartmentsAdapter(Context mContext, List&lt;DepartmentModel&gt; departmentsList){
          this.mContext = mContext;
          this.departmentsList = departmentsList;
      }
  
      @Override
      public int getCount() {
          return departmentsList.size();
      }
  
      @Override
      public Object getItem(int position) {
          return departmentsList.get(position);
      }
  
      @Override
      public long getItemId(int position) {
          return position;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          if (inflater == null)
              inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          if (convertView == null)
              convertView = inflater.inflate(R.layout.departments_list_item, null);
  
          DepartmentModel deptModel = (DepartmentModel) getItem(position);
  
          CheckBox deptChBox = (CheckBox) convertView.findViewById(R.id.deptCheckBox);
          TextView deptName = (TextView) convertView.findViewById(R.id.deptNameTextView);
  
          deptChBox.setTag(deptModel.departmentCode);
          deptName.setText(deptModel.departmentName);
  
          /*deptChBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
              @Override
              public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                  buttonView.getTag();
              }
          });*/
  
          return convertView;
      }
  }
  </code></pre>
  
  <p>Here is the snippet where i am setting that list to <code>AlertDialog</code> and where i am trying to get selected <code>checkboxes</code> from:</p>
  
  <pre><code> final DepartmentsAdapter departmentsAdapter = new DepartmentsAdapter(mActivity, deptList);
  
      mDialog = new AlertDialog.Builder(mActivity);
          mDialog.setCancelable(true);
          mDialog.setTitle(getResources().getString(R.string.departments));
          mDialog.setAdapter(departmentsAdapter, new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                  //Get from selection what you want
                  Log.e(Constants.TAG, "Clicked CheckBOx: " + which);
                  final String departmentCode = deptList.get(which).departmentCode;
              }
          });
  
      mDialog.show();
  </code></pre>