Reputation:
I want to include two layouts in one java class. How can I make it? I am using android studio. I want to use both layouts. And I want to use two buttons in different layouts from one java file. I am using setContentView but I am using a button from different activity too. So when I try my app, it crashes. I am using findviewbyid from different layout and app crashes. How can I block it?
Upvotes: 0
Views: 120
Reputation: 1506
If you have two separate layout files, you can use include to add those the layout you are inflating in that activity.
<include layout="@layout/layout1"/>
<include layout="@layout/layout2"/>
Add these inside the layout of that activity and you can then use the different layout and the buttons in them from the same activity.
Although without much clarity on your specific use case, the help we can give is limited.
Upvotes: 2