Loading activity in Fragment Code

﹥>﹥吖頭↗ 提交于 2019-12-13 03:38:58

问题


Can we load an activity (specifically in onCreateView) in fragment ? Instead of creating view by inflater, can we launch activity so it's events gets called ?

For e.g.

Instead of using "inflater.inflate(R.layout.tabactivity, null)", can we launch activity which uses "tabactivity" as layout ?


回答1:


Unfortunately this is not possible. You must create a Fragment Activity that will be used to refer to any fragment you create.

This is a good place to start:

Fragments Examples




回答2:


It's not possible you cannot add Activity inside a fragment. Fragment is part of UI component of Activity.

Refer below link

Docs for fragment in Android



来源:https://stackoverflow.com/questions/8510165/loading-activity-in-fragment-code

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