Android中的复选框->;运行错误

Android中的复选框->;运行错误,android,xml,checkbox,Android,Xml,Checkbox,我正在尝试制作一个带有3个复选框和1个按钮的简单应用程序。我想为每个复选框做一个祝酒词,看看它是否被选中(单击listener),然后为按钮实现一个单击listener,发布一条常规消息,看看是否选中了witch复选框 如果我只使用它在我手机上运行的简单按钮(Android版本4.1.1)输入代码,但如果我实现了这3个复选框,它就会崩溃(我会收到一个通知,如“你的应用程序停止运行,请单击强制关闭”) 我的xml: <?xml version="1.0" encoding="UTF-8"?&

我正在尝试制作一个带有3个复选框和1个按钮的简单应用程序。我想为每个复选框做一个祝酒词,看看它是否被选中(单击listener),然后为按钮实现一个单击listener,发布一条常规消息,看看是否选中了witch复选框

如果我只使用它在我手机上运行的简单按钮(Android版本4.1.1)输入代码,但如果我实现了这3个复选框,它就会崩溃(我会收到一个通知,如“你的应用程序停止运行,请单击强制关闭”)

我的xml:

<?xml version="1.0" encoding="UTF-8"?> 
<LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"
     android:gravity="center"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
>
    <Checkbox
         android:id= "@+id/ok_checkbox"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:text="@string/ok_read"
    />
    <Checkbox
         android:id= "@+id/removed_checkbox"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:text="@string/misspelled"
    />
    <Checkbox
         android:id= "@+id/changed_checkbox"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:text="@string/changed_read"
    />    
   <Button
         android:id= "@+id/final_click"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="@string/final_click" 
    />

  </LinearLayout>

我应该怎么做?

对于复选框,使用setOnCheckedChangeListener()如下-

        ok.setOnCheckedChangeListener(new OnCheckedChangeListener() 
        {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) 
            {
                if(isChecked)
                {
                    Toast.makeText(SecondActivity.this, "Your choice is OK",
                            Toast.LENGTH_LONG).show();
                }
            }
        });
其他复选框也是如此

        ok.setOnCheckedChangeListener(new OnCheckedChangeListener() 
        {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) 
            {
                if(isChecked)
                {
                    Toast.makeText(SecondActivity.this, "Your choice is OK",
                            Toast.LENGTH_LONG).show();
                }
            }
        });