I am trying to get the value of a EditText in a dialog box. A the "*"'ed line in the following code, the safeNameEditText is null; i am assuming because the 'findVeiwById' is searching on the context of the 'AlertDialog.OnClickListener'; How can I get/change the context of that 'findViewById' call?
protected Dialog onCreateDialog(int id) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
switch(id){
case DIALOG_NEW_SAFE:
builder.setTitle(R.string.news_safe);
builder.setIcon(android.R.drawable.ic_menu_add);
LayoutInflater factory = LayoutInflater.from(this);
View newSafeView = factory.inflate(R.layout.newsafe, null);
builder.setView(newSafeView);
builder.setPositiveButton(R.string.ok, new AlertDialog.OnClickListener(){
public void onClick(DialogInterface dialog, int which) {
* EditText safeNameEditText = (EditText) findViewById(R.id.new_safe_name);
String safeName = safeNameEditText.getText().toString();
Log.i(LOG, safeName);
setSafeDao(safeName);
}
});
builder.setNegativeButton(R.string.cancel, new AlertDialog.OnClickListener(){
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
return(builder.create());
default:
return(null);
}
}