I have to create an Android application using a custom dialog to check for passwords that match or do not match. When I click on my button to show the dialog, my application shuts down.
Her is my code as of now:

public class Lab08_MainActivity extends Activity
{
private static final int MY_PASSWORD_DIALOG_ID = 0;

@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lab08__main);
}

@Override
public boolean onCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.menu.activity_lab08__main, menu);
return true;
}

public void btnPasswordConfirmOnClick(View view)
{
showDialog(MY_PASSWORD_DIALOG_ID);
}

// creates the dialog
@Override
protected Dialog onCreateDialog(int id)
{
switch (id)
{
case MY_PASSWORD_DIALOG_ID:
// get the layout inflater and inflate the resource to a View
LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View layout = inflater.inflate(R.layout.lab08_password_dialog, (ViewGroup)findViewById(R.id.root));

// get the password editText
final EditText password1 = (EditText) layout.findViewById(R.id.EditText_Pwd1);
final EditText password2 = (EditText) layout.findViewById(R.id.EditText_Pwd2);
final TextView error = (TextView) layout.findViewById(R.id.TextView_PwdProblem);

password2.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
String strPass1 = password1.getText().toString();
String strPass2 = password2.getText().toString();
if (strPass1.equals(strPass2)) {
error.setText(R.string.pwd_equal);
} else {
error.setText(R.string.pwd_not_equal);
}
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
public void onTextChanged(CharSequence s, int start, int before, int count) {}
});

// create the Alert Dialog
AlertDialog.Builder builder = new AlertDialog.Builder(this);

// set your custom layout
builder.setTitle("Enter Password");
builder.setView(layout);

// create the Negative and Positive buttons
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
removeDialog(MY_PASSWORD_DIALOG_ID);
}
});
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
// get the msgTextView
TextView msgTextView = (TextView)findViewById(R.id.TextView_PwdProblem);
String strPass1 = password1.getText().toString();
String strPass2 = password2.getText().toString();
if (strPass1.equals(strPass2)) {

msgTextView.setText("Password: " + strPass1);
}
removeDialog(MY_PASSWORD_DIALOG_ID);
}
});

// create the Negative button
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
// get the msgTextView
TextView msgTextView = (TextView)findViewById(R.id.TextView_PwdProblem);
msgTextView.setText("Password Canceled");

removeDialog(MY_PASSWORD_DIALOG_ID);
}
});

// create and display the dialog
AlertDialog dialog = builder.create();
dialog.show();
} // end of switch
return super.onCreateDialog(id);
} // end of onCreate method
}