I'm currently making an app with bottomsheet feature which when the user taps an icon(imageview) inside the dialog the fragment will show up. my problem is I cant navigate to fragment b and it's returning me this error
this is my home fragment the one that starts first when the activity was launched
public class HomeFrag extends Fragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_home, container, false);
ImageView buttonOpenSheet = view.findViewById(R.id.buttonopensheet);
buttonOpenSheet.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
BottomSheetDialog bottomsheet = new BottomSheetDialog();
bottomsheet.show(getFragmentManager(), "bottomsheet");
}
});
return view;
}}
bottomsheetdialog.java
public class BottomSheetDialog extends BottomSheetDialogFragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.bottom_sheet, container, false);
//Views
ImageView usual = view.findViewById(R.id.usual);
final NavController navigator =
Navigation.findNavController(getActivity(), R.id.fragment_host);
usual.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
navigator.navigate(R.id.action_bottomSheetDialog_to_usualFrag);
Log.d(TAG, "user clicked" );
}
});
return view;
}}
this is my navigation
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/app_nav"
app:startDestination="@id/homeFrag">
<fragment
android:id="@+id/homeFrag"
android:name="com.bw.f22920.HomeFrag"
android:label="fragment_home"
tools:layout="@layout/fragment_home" />
<dialog
android:id="@+id/bottomSheetDialog"
android:name="com.bw.f22920.BottomSheetDialog"
android:label="bottom_sheet"
tools:layout="@layout/bottom_sheet">
<action
android:id="@+id/action_bottomSheetDialog_to_usualFrag"
app:destination="@id/usualFrag" />
</dialog>
<fragment
android:id="@+id/usualFrag"
android:name="com.bw.f22920.UsualFrag"
android:label="fragment_usual"
tools:layout="@layout/fragment_usual" />
</navigation>