A
A
Alexey2016-05-22 11:34:50
Android
Alexey, 2016-05-22 11:34:50

TabLayout, Fragments and Activities?

Hello! New to Android. I would like to write an application for various timetables, primarily for schoolchildren and students. The application, according to my idea, consists of a NavigationDrawer with the following tabs: Schedule, Grades, Exams (and tests) and Assignments. In the tab with the schedule, there should be a TabLayout with the days of the week. The essence of the question is as follows, according to its implementation, NavigationDrawer should work with fragments (as I understand Google's idea), so that it (NavigationDrawer) is available throughout the application, NavigationDrawer disappears with Activities. Duck here, How it is possible to implement the structure described above? I tried to create a fragment with tabs, when you click on the day of the week, a fragment with the day of the week appears, but this approach seems incorrect to me, because when you run the app, fragments work fine, but if in the NavigationDrawer we go, for example, to Grades and then return to the Schedule, then after that the fragments do not display anything and the tabs do not switch correctly, i.e. how far he swiped his finger, how much the taba moved, while there is zero information on it. If you manually click on the last or penultimate taboo, then information appears there and then the tabs start working normally.
What to do in this situation, I do not know. Googling didn't turn up much. Almost everywhere TabLayout is implemented inside the Activity, and not in the fragment. And in this case, there will be tabs in all fragments. Or is there still some way to combine tabs, activity and NavigationDrawer?
and is it possible to somehow remove the tabs when calling a fragment, if they are organized at the activity level?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
Conacry, 2016-05-24
@Conacry

Hello. I advise you to read this book: https://habrahabr.ru/company/piter/blog/277023/. It's just good for beginners. It just very well parsed a similar application.

A
Alexey, 2016-05-24
@vaseel1ch

I recently read this book and it didn't have what I needed. A bug due to the crooked display of cards and lags was discovered. It was all because of the studio, or rather because of the instant run, which updated the displayed fragments. The implementation I described is correct. Everything is working. I was answered with this question on stackoverflow. So the question is no longer relevant.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question