I think I followed the Android tutorial quite closely here. I have a ListActivity which calls a showDialog(DIALOG_EXPORT); at some point. My onCreateDialog() creates a dialog, sets an xml view and then tries to do something with the elements of that dialog, but directly after findViewById() everything is null. Why?
here the code:
protected Dialog onCreateDialog(int id) {
switch(id){
case DIALOG_EXPORT:
final Dialog dial = new Dialog(this);
dial.setContentView(R.layout.export_dialog);
dial.setTitle(R.string.dialog_export_title);
EditText eFile = (EditText) findViewById(R.id.e_dialog_export);
Button bOkay = (Button) findViewById(R.id.b_export_okay);
Button bCancel = (Button) findViewById(R.id.b_export_cancel);
<here all View elements are empty>
...
return dial;
...
}
}
You need to use
dial.findViewById()instead of justfindViewById()