How to start an Activity inside a Fragment class

可紊 提交于 2020-01-17 16:34:48

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!