Android custom dialog with button

hope

New Member
Very simple question today. When I attempt to retreive a reference to the button on the dialog I always receive a null value.\[code\]@Overridepublic void onRestart() { super.onRestart(); //must prompt with modal dialog for pin Dialog dialog = new Dialog(this); dialog.setOwnerActivity(this); dialog.setCancelable(false); //check pin dialog.setCanceledOnTouchOutside(false); //set view to enterpin XML screen dialog.setContentView(R.layout.enterpin); //register button //show dialog dialog.show(); //listen for button being clicked Button button = (Button) findViewById(R.id.pinlogin); button.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v){ EditText editText = (EditText) findViewById(R.id.enterpin); int enteredPin = Integer.parseInt(editText.getText().toString()); SharedPreferences sharedP = getPreferences(MODE_PRIVATE); int temp = sharedP.getInt("pin", 0); if(enteredPin==temp){ pinCheck = true; }else{ pinCheck = false; } } }); if(pinCheck){ dialog.dismiss(); }}\[/code\]Yes the button exists, no I did not mispell it's reference. Yes I've cleaned the project and restarted eclipse. How can the button not be associated with the view when i clearly called setContentView()? I'm sure it's simple, I've never used dialogs before, new to GUI in general. Especially Android
 
Back
Top