问题
I have two tabs.First tab is for map .Second tab is for list. And I tried to display the map on the first tab. But it has displayed only the layout [return inflater.inflate(R.layout.map_activity, container, false);] But instead of this I have one activity for map, i want to load that activity without losing tab ,inside the tab itself.Please help me
回答1:
As you told you want to show activity in fragment, Your tabs are fragments. I want to make clear that Fragment
cant host Activity
. Your Activty
can have multiple fragments, but fragments cannot have fragments inside them. You don't have alternatives than making it Fragment
if you really want to show it in tab. If you are trying to show something more in same tab so that you don't want to make it fill the entire screen and start a new Activity
then there is options of Nested Fragments. You can show half screen as map and half as you want inside same tab.
来源:https://stackoverflow.com/questions/35966756/how-to-start-an-activity-inside-a-fragment-class