How to set button click listener for Custom Dialog?
<p>I have made a main Dialog class on which i send the layout id and shows the Layout as a Dialog now when i send the layout from calling class it pops up the dialog but the contents of dialog i.e. buttons are inaccessible i can't set click listener for them...help me how to do this below is my code...</p>

<p>CALLING CLASS:-</p>

<pre><code>   CustomDialog obj=new CustomDialog(MailSenderActivity.this , R.layout.mydialog);
obj.show();
</code></pre>

<p>MAIN CLASS</p>

<pre><code>import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class CustomDialog extends Dialog implements
View.OnClickListener {
    Dialog dialog;
    int id;


    public CustomDialog(MailSenderActivity mailsender, int id) {
        super(mailsender);
        this.id = id;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(id);



        Button signInbutton=(Button)findViewById(R.id.signInButton);

        Button closebutton=(Button)findViewById(R.id.closeButton);




        }






    public void closebutton(View v) {
        Toast.makeText(getContext(), "You clicked a button!", Toast.LENGTH_LONG).show();
        dismiss();

    }

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub

    }
}
</code></pre>

<p>id is:-</p>

<pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="fill_parent" android:layout_width="fill_parent"
    android:padding="30dip" android:orientation="horizontal"
    android:weightSum="1"
    android:background="@drawable/gmail"&gt;
    &lt;LinearLayout android:layout_width="296dp"
        android:orientation="vertical" android:layout_gravity="center"
        android:layout_weight="1.51" android:layout_height="497dp"&gt;
        &lt;TextView android:text="My Dialog" android:textSize="24.5sp"
            android:layout_width="wrap_content" android:layout_gravity="center"
            android:layout_height="wrap_content" android:layout_marginBottom="25dip"&gt;&lt;/TextView&gt;
        &lt;TextView android:text="Enter Gmail Id" android:layout_width="fill_parent"
            android:layout_height="wrap_content"&gt;&lt;/TextView&gt;
        &lt;EditText android:id="@+id/name" android:layout_width="358dp"
            android:singleLine="true" android:layout_height="wrap_content"&gt;

        &lt;/EditText&gt;
        &lt;TextView android:text="Enter Gmail Password"
            android:layout_width="fill_parent" android:layout_height="wrap_content"&gt;&lt;/TextView&gt;
        &lt;EditText android:id="@+id/name" android:layout_width="314dp"
            android:singleLine="true" android:layout_height="wrap_content"
            android:password="false" android:inputType="textPassword"&gt;&lt;/EditText&gt;
        &lt;Button android:text="Sign In" android:layout_width="67dp"
            android:id="@+id/signInButton" android:layout_height="wrap_content"
            android:clickable="true" android:onClick="signIn"&gt;&lt;/Button&gt;

        &lt;Button android:text="close" android:layout_width="67dp"
            android:id="@+id/closeButton" android:layout_height="wrap_content"
            android:clickable="true" android:onClick="closeButton"&gt;&lt;/Button&gt;
    &lt;/LinearLayout&gt;
&lt;/LinearLayout&gt;
</code></pre>
