The UI
elements in the MainActivity
class need to be preserved and the other class file adds a new UI
element to the main xml
layout that's used by both classes to differing degrees.
It's understood that you can create a base abstract class and two concrete inherited classes however in this case there a third supporting class for the second (other class) and it requires a handler to function.
For perspective, a button (in activity_main
) is clicked and it should launch an activity while maintaining the UI
elements used MainActivity
. Furthermore the button has it's own class file methods and isn't in MainActivity
.
What happens now? The button is pressed and nothing happens. Manifest confirmed so its not that. Or I allow the main activity or the other activity and it works, both need to work simultaneously.
Basically MainActivity
needs to act as the base abstract activity for the separate class file.
You are messing up activities and views. To reuse the same business logic, you can write common logic in base class for all other activities (ie class BaseActivity extends Activity
). To reuse different UI
parts you should either use fragments or you can use <include>/<merge>
tags pair to include a certain layout into another layout.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.