Search code examples
androidbottom-sheetparameterized-class

Raw use of parameterized class on Android Studio


I have this code on my Android project:

final BottomSheetBehavior infoBottomSheetBehavior = BottomSheetBehavior.from(findViewById(R.id.info_view));
        infoBottomSheetBehavior.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
            @Override
            public void onStateChanged(@NonNull View bottomSheet, int newState) {
                if (newState == BottomSheetBehavior.STATE_DRAGGING) {
                    infoBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
                }
            }
            @Override
            public void onSlide(@NonNull View bottomSheet, float slideOffset) {
            }
        });

And the next warning appears over BottomSheetBehavior: Raw use of parameterized class 'BottomSheetBehavior'

Does anybody know how to avoid this warning?


Solution

  • Ok, here is the so basic answer from a coffee talk...

    final BottomSheetBehavior<View> infoBottomSheetBehavior = BottomSheetBehavior.from(findViewById(R.id.info_view));
            infoBottomSheetBehavior.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
                @Override
                public void onStateChanged(@NonNull View bottomSheet, int newState) {
                    if (newState == BottomSheetBehavior.STATE_DRAGGING) {
                        infoBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
                    }
                }
                @Override
                public void onSlide(@NonNull View bottomSheet, float slideOffset) {
                }
            });
    

    I've just missed the <View>