Je recherche beaucoup, mais n'a pas pu trouver de solution et Snackbar is not working within fragment class n'a pas aidé. Je passe rootView du fragment et essaye aussi de passer une vue de getActivity mais aucun ne fonctionne!Comment afficher SnackBar dans BottomSheetDialogFragment?
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.content_dialog_bottom_sheet, container, false);
Snackbar.make(MyActivity.myTextview, "Hello", Snackbar.LENGTH_INDEFINITE).show();
Snackbar.make(rootView, "Hello", Snackbar.LENGTH_INDEFINITE).show();
return rootView;
}
et mon content_dialog_bottom_sheet:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bottomSheetLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background"
app:behavior_hideable="true"
app:behavior_peekHeight="180dp"
app:layout_behavior="@string/bottom_sheet_behavior">
//some views
</RelativeLayout>
Ajouter un code s'il vous plaît – ImAtWar
@ImAtWar J'ai ajouté –
Voir s'il vous plaît votre code de fichier de mise en page. – ImAtWar