Dynamically create an activity

后端 未结 4 1804
礼貌的吻别
礼貌的吻别 2021-01-04 02:07

I want to create an activity dynamically. Something like:

Activity a = new Activity();

Is it possible ? Do I need a special permission ? Or

相关标签:
4条回答
  • 2021-01-04 02:18

    You can't instantiate an Activity if it's not in the Manifest, so you can't create one dynamically.

    0 讨论(0)
  • 2021-01-04 02:22

    Instead of multiple activities you can Fragments. You can use the same Layouts with Fragments and you can instantiate them dynamically and remove. In this way you can create a stack based application.

    0 讨论(0)
  • 2021-01-04 02:38

    are you trying to start an activity?

    use context.startActivity(intent); where the intent defines what activity you want to start.

    0 讨论(0)
  • 2021-01-04 02:40

    You can't create activity at run time so what you can u is create Layouts at the run time and change the layout according to the event...

    here you are going to use layout change instead of starting a new activity

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