Я знаю привязку данных с помощью ViewModel в действиях, а также фрагмент с одной раздутой строкой, но что если я использую несколько строк и меняю их во время выполнения?
Код: Inside onCreateView:
приватный просмотр rootViewHistory, rootViewExamination, rootViewDiuagnosis, rootViewOrders;
private void setAndReplaceViews(LayoutInflater inflater, @Nullable ViewGroup container) {
switch (getArguments().getInt(ARG_SECTION_NUMBER)) {
case 1:
if (rootViewHistory == null) {
try {
rootViewHistory = inflater.inflate(R.layout.fragment_history, container, false);
} catch (Exception e) {
e.printStackTrace();
}
}
break;
case 2:
if (rootViewExamination== null) {
try {
rootViewHistory = inflater.inflate(R.layout.fragment_examination, container, false);
} catch (Exception e) {
e.printStackTrace();
}
}
break;
case 3:
if (rootViewDiuagnosis== null) {
try {
rootViewHistory = inflater.inflate(R.layout.fragment_diagnosis, container, false);
} catch (Exception e) {
e.printStackTrace();
}
}
break;
case 4:
if (rootViewOrders== null) {
try {
rootViewHistory = inflater.inflate(R.layout.fragment_orders, container, false);
} catch (Exception e) {
e.printStackTrace();
}
}
break;
}