I have a DialogPreference, that I'm trying to get a Fragment that is added to it (Google Maps, if anyone cares). The fragment has an id tag in the XML code, and I'm setting the dialog via setDialogLayoutResource()
. However, I'm struggling to get a reference to the fragment (So I can set some settings to it, and get data out from it). I need to get a reference to it before the user can start playing with the data.
What I've tried so far is this:
@Override
protected void onBindDialogView(View view) {
((Fragment) getDialog()
.getOwnerActivity()
.getFragmentManager()
.findFragmentById(R.id.map));
}
This doesn't work because getDialog returns null at this point in the lifecycle. If there's a better way to reference the activity or FragmentManager, I'd love to see it. Thanks for the help!