I have the following XML
<?xml version="1.0" encoding="utf-8"?>
<layout>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fragment_inspection_details_root"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="@dimen/size_0dp"
android:layout_height="@dimen/size_0dp"
app:layout_constraintBottom_toTopOf="@+id/fragment_inspection_details_buttons_container"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/fragment_inspection_details_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/size_16dp"
android:text="@string/details"
android:textAllCaps="true"
android:textColor="@color/gold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:layout_width="@dimen/size_0dp"
android:layout_height="1dp"
android:layout_margin="@dimen/size_16dp"
android:background="@color/lightGray"
app:layout_constraintBottom_toBottomOf="@+id/fragment_inspection_details_title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/fragment_inspection_details_title"
app:layout_constraintTop_toTopOf="@+id/fragment_inspection_details_title" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/fragment_inspection_details_status_til"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="@dimen/size_0dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/size_16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/fragment_inspection_details_title">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/fragment_inspection_details_status_tie"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:hint="@string/status" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/fragment_inspection_details_start_time_til"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="@dimen/size_0dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/size_16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/fragment_inspection_details_status_til">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/fragment_inspection_details_start_time_tie"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:hint="@string/start_time" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/fragment_inspection_details_end_time_til"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="@dimen/size_0dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/size_16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/fragment_inspection_details_start_time_til">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/fragment_inspection_details_end_time_tie"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:hint="@string/end_time" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/fragment_inspection_details_desc_time_til"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="@dimen/size_0dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/size_16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/fragment_inspection_details_end_time_til">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/fragment_inspection_details_desc_time_tie"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:hint="@string/description" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="@+id/fragment_inspection_details_handling_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/size_16dp"
android:text="@string/handling"
android:textAllCaps="true"
android:textColor="@color/gold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/fragment_inspection_details_desc_time_til" />
<View
android:layout_width="@dimen/size_0dp"
android:layout_height="1dp"
android:layout_margin="@dimen/size_16dp"
android:background="@color/lightGray"
app:layout_constraintBottom_toBottomOf="@+id/fragment_inspection_details_handling_title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/fragment_inspection_details_handling_title"
app:layout_constraintTop_toTopOf="@+id/fragment_inspection_details_handling_title" />
<TextView
android:id="@+id/fragment_inspection_details_outcome_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/size_16dp"
android:text="@string/outcome"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/fragment_inspection_details_handling_title" />
<Spinner
android:id="@+id/fragment_inspection_details_outcome_spinner"
android:layout_width="@dimen/size_0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/size_8dp"
android:layout_marginEnd="@dimen/size_16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/fragment_inspection_details_outcome_title" />
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="@dimen/size_0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/size_16dp"
android:layout_marginEnd="@dimen/size_16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/fragment_inspection_details_outcome_spinner">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/fragment_inspection_details_outcome_report_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Outcome report" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
<LinearLayout
android:id="@+id/fragment_inspection_details_buttons_container"
android:layout_width="@dimen/size_0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<androidx.appcompat.widget.AppCompatButton
android:layout_width="@dimen/size_0dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/size_16dp"
android:layout_weight="1"
android:background="@drawable/white_background_gray_rounded_border"
android:text="@string/save"
android:textAllCaps="false" />
<androidx.appcompat.widget.AppCompatButton
android:layout_width="@dimen/size_0dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/size_16dp"
android:layout_weight="1"
android:background="@drawable/white_background_gray_rounded_border"
android:text="@string/handle"
android:textAllCaps="false" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
and the following code -
class InspectionDetailsFragment : Fragment() {
companion object {
fun newInstance(inspection: Inspection): InspectionDetailsFragment {
val inspectionDetailsFragment = InspectionDetailsFragment()
val bundle = Bundle()
bundle.putParcelable(Constants.INSPECTION, inspection)
inspectionDetailsFragment.arguments = bundle
return inspectionDetailsFragment
}
}
...
...
}
//Inside another Fragment
changeFragment(
parentFragmentManager, R.id.fragment_inspection_details_root,
InspectionDetailsFragment.newInstance(inspection), true
)
// Change fragment extension function to handle navigation easily
@SuppressLint("PrivateResource")
fun changeFragment(fragmentManager: FragmentManager?, @IdRes containerId: Int, fragment: Fragment?, addToBackStack: Boolean = false) {
if (fragmentManager == null) return
val fragmentTransaction = fragmentManager.beginTransaction()
if (addToBackStack) fragmentTransaction.addToBackStack(null)
/*fragmentTransaction.setCustomAnimations(
R.anim.abc_fade_in,
R.anim.abc_shrink_fade_out_from_bottom,
R.anim.abc_grow_fade_in_from_bottom,
R.anim.abc_popup_exit
)*/
fragment?.let {
fragmentTransaction
.replace(containerId, it, it::class.java.simpleName)
.commit()
}
}
For some reason when trying to navigate to the InspectionDetailsFragment the app crashes with the No view found for id 0x7f0900df (com.supercom.myapplication:id/fragment_inspection_details_root) for fragment InspectionDetailsFragment
I really have no idea what's wrong, I tried to look up but it seems like I am doing everything correct.
The InspectionDetailsFragment used to have a container fragment for it but I deleted it, maybe that is related to the issue I am getting?