I have this code, where I define my own AlertDialog.Builder
:
public class UnlockDialog extends AlertDialog.Builder {
public UnlockDialog(Activity context) {
super(context);
LayoutInflater inflater = context.getLayoutInflater();
View dlgView = inflater.inflate(R.layout.unlock_dialog, null);
setView(dlgView);
}
}
the code works fine, but I get a warning on the inflater.inflate
call:
Avoid passing null as the view root (needed to resolve layout parameters on the inflated layout's root element)
I had this issue as well in my adapters, where I could resolve it using providing a parent
and false
, as I found here: Avoid passing null as the view root (need to resolve layout parameters on the inflated layout's root element)
However, in the case above, I don't seem to have a parent
available. I tried context.getParent()
, but that didn't work.