Trying to inflate a custom layout for an AlertDialog, but keep getting this waring. I've seen several different solutions to this but don't know which is correct for my scenario. What is the actual correct way of getting rid of this null warning?
Avoid passing null as the view root (need to resolve layout parameters on the inflated layout's root element)
@Override
public void onClick(View v) {
AlertDialog alertDialog = new
AlertDialog.Builder(getActivity()).create();
LayoutInflater inflater = getActivity().getLayoutInflater();
View content = inflater.inflate(R.layout.dialog_customd, null);
alertDialog.setView(content);
alertDialog.show();
}
You may try to use:
View.inflate(context, R.layout.dialog_customd, null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With