can't set listener of button on dialog?
<p>I have a problem with event listener of button on dialog.
I have a quickAction, when i click item on menu quick action, i want show a dialog,
and i want set clickListener for buton YES and NO. Please help me!
My code:
in function onCreate(), i declare </p>

<pre><code>dialog1 = new Dialog(this,R.style.FullHeightDialog);    
        btnDialogYes = (Button)dialog1.findViewById(R.id.bmessageDialogYes);
        btnDialogNo = (Button)dialog1.findViewById(R.id.bmessageDialogNo);
        message = (TextView)dialog1.findViewById(R.id.tvmessagedialogtext);
        dialog1.setContentView(R.layout.custom_dialog);
        dialog1.setCancelable(true);
</code></pre>

<p>and </p>

<pre><code>class MyClass implements OnClickListener{

}
</code></pre>

<p>and i override </p>

<pre><code>onClick(){
        switch(v.getId()){
            case R.id.bmessageDialogYes:{
                board.setCurrentPiece(Board.WHITE);
                threadComputer = new myThread(doBackgroundThreadProcessing);
                threadComputer.start();
                dialog1.dismiss();
                break;              
            }
            case R.id.bmessageDialogNo:{
                board.setCurrentPiece(Board.BLACK);
                threadComputer = new myThread(doBackgroundThreadProcessing);
                threadComputer.start();
                dialog1.dismiss();
                break;              
            }

        }
}
</code></pre>

<p>when i click item of menu quickaction, i call mention Play()</p>

<pre><code>Play(){
     message.setText("YES to AI first play!");      
        btnDialogYes.setOnClickListener(this); // error here
        btnDialogNo.setOnClickListener(this);

        dialog1.show();
}
</code></pre>

<p>but when i run app not work, and i have check id of widget in file layout :(</p>

<pre><code>my layout
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout_root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff"
    android:orientation="vertical" &gt;

    &lt;LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:orientation="horizontal" &gt;

        &lt;!-- This is for the info image --&gt;
        &lt;ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:src="@android:drawable/ic_menu_info_details" /&gt;

        &lt;!-- Title --&gt;
        &lt;TextView
            android:id="@+id/tvmessagedialogtitle"
            android:layout_width="184dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="4dip"
            android:layout_weight="0.01"
            android:padding="8dp"
            android:text="Message"
            android:textColor="#343434"
            android:textSize="16dip"
            android:textStyle="normal"
            android:typeface="normal" /&gt;
    &lt;/LinearLayout&gt;

    &lt;!-- Underline with this bluish color --&gt;
    &lt;View
        android:layout_width="fill_parent"
        android:layout_height="2dip"
        android:background="#09adb9" /&gt;

    &lt;!-- The message --&gt;
    &lt;TextView
        android:id="@+id/tvmessagedialogtext"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:layout_marginBottom="10dp"
        android:layout_marginTop="4dip"
        android:gravity="left"
        android:padding="8dp"
        android:text="Message"
        android:textColor="#343434"
        android:textSize="15dip"
        android:textStyle="normal"
        android:typeface="normal" /&gt;

    &lt;LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:orientation="horizontal" &gt;

        &lt;!-- Yes button --&gt;
        &lt;Button

            android:id="@+id/bmessageDialogYes"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="4dip"
            android:layout_marginLeft="60dp"
            android:background="#ffffff"
            android:padding="8dp"
            android:text="Yes"
            android:textColor="#343434"
            android:textSize="13dip"
            android:textStyle="normal"
            android:typeface="normal" /&gt;

        &lt;!-- No Button --&gt;

        &lt;Button
            android:id="@+id/bmessageDialogNo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="4dip"
            android:layout_marginLeft="80dp"
            android:background="#ffffff"
            android:padding="8dp"
            android:text="No"
            android:textColor="#343434"
            android:textSize="13dip"
            android:textStyle="normal"
            android:typeface="normal" /&gt;
    &lt;/LinearLayout&gt;

&lt;/LinearLayout&gt;

logcat
02-17 19:34:38.760: E/AndroidRuntime(374): FATAL EXCEPTION: main
02-17 19:34:38.760: E/AndroidRuntime(374): java.lang.NullPointerException
02-17 19:34:38.760: E/AndroidRuntime(374):  at my.quoc.caro_final.ComputerActivity.Play(ComputerActivity.java:254)
02-17 19:34:38.760: E/AndroidRuntime(374):  at my.quoc.caro_final.ComputerActivity.access$4(ComputerActivity.java:219)
02-17 19:34:38.760: E/AndroidRuntime(374):  at my.quoc.caro_final.ComputerActivity$2.onItemClick(ComputerActivity.java:68)
02-17 19:34:38.760: E/AndroidRuntime(374):  at my.quoc.caro_final.QuickAction$2.onClick(QuickAction.java:169)
02-17 19:34:38.760: E/AndroidRuntime(374):  at android.view.View.performClick(View.java:2485)
02-17 19:34:38.760: E/AndroidRuntime(374):  at android.view.View$PerformClick.run(View.java:9080)
02-17 19:34:38.760: E/AndroidRuntime(374):  at android.os.Handler.handleCallback(Handler.java:587)
02-17 19:34:38.760: E/AndroidRuntime(374):  at android.os.Handler.dispatchMessage(Handler.java:92)
02-17 19:34:38.760: E/AndroidRuntime(374):  at android.os.Looper.loop(Looper.java:123)
02-17 19:34:38.760: E/AndroidRuntime(374):  at android.app.ActivityThread.main(ActivityThread.java:3683)
02-17 19:34:38.760: E/AndroidRuntime(374):  at java.lang.reflect.Method.invokeNative(Native Method)
02-17 19:34:38.760: E/AndroidRuntime(374):  at java.lang.reflect.Method.invoke(Method.java:507)
02-17 19:34:38.760: E/AndroidRuntime(374):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-17 19:34:38.760: E/AndroidRuntime(374):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-17 19:34:38.760: E/AndroidRuntime(374):  at dalvik.system.NativeStart.main(Native Method)
02-17 19:34:40.700: I/Process(374): Sending signal. PID: 374 SIG: 9
</code></pre>
