I’m trying to generate a custom dialog in Android.
I create my Dialog like this:
dialog = new Dialog(this);
dialog.setContentView(R.layout.my_dialog);
Everythings works fine except for the title of the Dialog.
Even if I don’t set the title of the dialog the dialog popup has a blank space at the position of the dialog.
Is there any way to hide this part of the Dialog?
I tried it with an AlertDialog but it seems the layout is not set properly:
LayoutInflater inflater =
(LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.map_dialog, null);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(view);
// dialog = new Dialog(this);
// dialog.setContentView(R.layout.map_dialog);
dialog = builder.create();
((TextView) dialog.findViewById(R.id.nr)).setText(number);
If I use this code I get a null Pointer Exception in the last line. The dialog is not null so the TextView I try to retrieve does not exist.
If I uncomment the part where I use the Dialog Constructor everything works fine but for the title above my dialog layout.