title: How to have a dialog with a design from xml?
body: <p>What I want to do is to show a Dialog with a couple of options that I designed in xml.
  Here is how the code looks:</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.test_main);
  
      Dialog_Choices(); 
  }
  public void Dialog_Choices()
  {
       Dialog dialog = new Dialog(Main.this);
       dialog.setContentView(R.layout.test_dialog);
  
       Button_FinishOne=(Button)findViewById(R.id.Ramadan_Button_FinishOne);
      Button_FinishTwo=(Button)findViewById(R.id.Ramadan_Button_FinishTwo);
      Button_FinishThree=(Button)findViewById(R.id.Ramadan_Button_FinishThree);
  
       dialog.setTitle("اختار عدد مرات");
       dialog.setCancelable(false);
  
  
      Button_FinishOne.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              Toast.makeText(Main.this, "One", Toast.LENGTH_SHORT).show();                
          }
      });
  
      dialog.show();
  }
  </code></pre>
  
  <p>The problem is that Button_FinishOne is null when it reaches SetOnClickListener..</p>
  
  <p>If I change the SetContentView in the OnCreate to (R.layout.test_dialog) , it works.</p>
  
  <p>R.layout.test_dialog has 3 buttons in a relativeView</p>
  
  <p>R.layout.test_main has a listview.</p>
  
  <p>How can I have a xml layout for the main Activity, and another xml for the dialog?</p>
  
  <p>Thanks.</p>