Is there a simple way to copy Android activities in the same project

I have an activity that works well as another part of the application I'm developing with some modifications. I want to know if I can easily copy an activity in Android studio without manually copying all its dependencies (for example, activity_my. XML)

resolvent:

Use it correctly: you have code to reuse in another activity

Now, I will not do this by copying the reused code (because if I want to modify it, I have to modify two copies, which is cumbersome work)

I'm going to create a basic activity that has the functionality you need for both activities. This functionality must be slightly abstracted so that both activities can use this functionality by extending this baseactivity and use it for their respective purposes

If you publish some code (which should be included in the code sections of both activities), I can update the answer to show you your situation

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>