title: Close Alert Dialog
body: <p>Close Alert Dialog on clicking the <code>Cancel</code> button is not working. <code>Dismiss()</code> is not working for <code>Alert/dialog</code>. Please suggest what to write in the <code>Onclick</code> button event.</p>
  <pre><code> @Override
              public void onClick(View v) {
             // Toast toast=Toast.makeText(getActivity(), &quot;Enter number of households here&quot;, Toast.LENGTH_SHORT);
  
  
             final ViewGroup subview=(ViewGroup) getLayoutInflater().
                               inflate(R.layout.edittext_info_dialog,null,false) ;
             TextView tv = (TextView) subview.findViewById(R.id.Info_Title);
             tv.setText(&quot;Enter number of household in village here&quot;);
  
             final AlertDialog.Builder builder=  new AlertDialog.Builder(getContext());
  
  
                    builder.setView(subview);
                    builder .show();
  
                    
  
            Button Cancel=(Button) subview.findViewById(R.id.Cancel_Info);
            Cancel.setOnClickListener(new View.OnClickListener() {
                
  
                @Override
                public void onClick(View v) {
                 Toast.makeText(getContext(),&quot;Cancel&quot;,Toast.LENGTH_LONG).show();
                 
                }
            });
  
              }
          });
  </code></pre>