Cannot find a child SupportMapFragment from an AndroidX Fragment
See original GitHub issueI think this is a known issue on the Google side, but I’m not sure if it has been sorted yet or is going to propagate to Xamarin soon:
I have a SupportMapFragment, which inherits Support.V4.App.Fragment. Before I migrated to AndroidX I had this line:
_mapFragment = (SupportMapFragment)ChildFragmentManager.FindFragmentById(Resource.Id.map);
Now I get a casting error because the AndroidX fragment’s child fragment manager doesn’t return a support fragment.
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (3 by maintainers)
Top Results From Across the Web
SupportMapFragment does not support AndroidX Fragment
Looking at the error message you posted, I suspect this was the main issue in your case. The definition in your layout file...
Read more >SupportMapFragment | Maps SDK for Android
This fragment is the simplest way to place a map in an application. It's a wrapper around a view of a map to...
Read more >How to find a child Fragment with Navigation Architecture ...
findFragmentById (R.id.map) as SupportMapFragment actually find a nested navigation graph. If you just want to get access to your child fragment, ...
Read more >Create Google Map with MVVM Live Data in Fragment with ...
SupportMapFragment 3) Edit the created Fragment.kt file to remove ... First, it will check to see if the map is ready, and if...
Read more >Android SupportMapFragment Example
The reason for doing this is, we need to use a method getSupportFragmentManager(), and this method can be called in FragmentActivity class only....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
What if you use:
@Ryan-Palmer Thank-you for all your help! Sorry for the confusion - I had previously used an xml layout with a SupportMapFragment with the V4 support libs. I have now gone back to that code. Given your help with the
JavaCast<SupportMapFragment>()
the nested fragment is now working fine.I am not sure when or why I changed my code, but having an xml layout for a UI fragment seems correct even if it is only has a SupportMapFragment based fragment contained within it.
Thanks again Ryan!