Fragment without activity

后端 未结 7 1764
夕颜
夕颜 2020-12-29 06:14

I have been asked an interview question: Can a fragment exist without activity? I searched for answers but didn\'t get a proper answer and explanation. Can

相关标签:
7条回答
  • 2020-12-29 06:46

    It can exist as an object in memory (by creating it with new), but it needs to be attached to an Activity in order to appear on the screen, assuming it has any UI (fragments don't have to have UI).

    0 讨论(0)
提交回复
热议问题