Perhaps I’m missing something obvious here, but I’m having a hard time setting a custom view for the body of an AlertDialog. Here’s what I’m doing to set the custom view:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(View.inflate(getContext(), R.layout.dialog_body, null));
}
Instead of setting the content of the body of the AlertDialog, the view is placed over the entire screen. How do I get the view just to replace the AlertDialog message body?
You are setting the activity’s view by calling
setContentViewwhich is why it takes up the entire screen. You are also doing it in theonCreatemethod of what I assume is the activity, you need to do it in theonCreateDialogmethod.Heres a link to the docs and an example.