问题
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