4

我的 Android 项目中有以下代码:

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) {
            }
        });

下一个警告出现在 BottomSheetBehavior:Raw use of parameterized class 'BottomSheetBehavior'

有谁知道如何避免这个警告?

4

1 回答 1

16

好的,这是咖啡谈话的基本答案......

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) {
            }
        });

我刚刚错过了<View>

于 2020-08-05T12:26:26.477 回答