G
G
Gibbzy2017-08-28 05:12:26
Android
Gibbzy, 2017-08-28 05:12:26

How to properly include layouts in an android application?

Here I have a drawlerLayout inside it includes @layout/app_bar inside app_bar includes @layout/content_main
So here I click a menu item in this very drawer and I want something else to be included instead of content_main.
How can I do it ?
I can use
setContentView();
but then I'll have to duplicate @layout/app_bar and the root drawlerLayout, and I'm not completely stupid, I understand that this is bad.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrei K, 2017-08-28
@gibbzy

Understood nothing. Do you need to organize navigation in an application based on the Navigation Drawer? Then google towards Navigation Drawer.
There are several implementation options, but the most obvious is one host activity with DrawerLayout + Toolbar and menu screens on fragments. To do this, you need to remove the content_main and instead put a FrameLayout and use it as a normal container for the fragment. When a menu is clicked in the Navigation Drawer, the host activity simply changes fragments.
Naturally, each fragment has its own layout.
app_bar_main.xml
bebb95356dbe45c9b7d1103840a17fc6.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question