Please see my previous question for details on how it works.
Current Setup
I have created a class called SherlockMapFragment inside the ActionBarSherlock(ABS) library which extends SupportMapFragment. This works fine to display the map etc and I didn’t realise until now (because I’m an idiot) the following:
- I created an instance of SherlockMapFragment called mapFrag.
- Then to use and display this I call mapFrag.newInstance().
What this is actually doing is returning an instance of SupportMapFragment however this call is necessary to get the MapView displayed.
This is a huge problem for what I am trying to achieve because I am trying to add my Fragments into a tabbed navigation bar but obviously I cannot add a SupportMapFragment to a TabListener because I get all sorts of class cast exceptions etc as its expecting an extension of SherlockFragment or Fragment.
Can anyone see a way round this? Or if I need to make myself clearer please just ask the question.
One Possible Solution
One solution is to create my own tab bar and handle the transaction of Fragments myself. However, the tools are already there and I don’t really want to be doing this if its a simple fix.
Thanks in advance
You could extends SherlockFragment and handle the MapView yourself. This would look something like…
Nothing says you absolutely MUST use SupportMapFragment. One of the coolest parts of the new API is the ability to use the MapView as a normal View.