NullPointerException with AppCompat BottomSheets

前端 未结 5 1552
LinearLayout bottomSheetViewgroup = (LinearLayout) findViewById(R.id.bottomSheet);

bottomSheetBehavior = BottomSheetBehavior.from(bottomSheetViewgroup);

bottomShee         


        
5条回答
  •  半阙折子戏
    2020-12-20 12:28

    public class ExpandedBottomSheetBehavior extends
        android.support.design.widget.BottomSheetBehavior {
    
      public ExpandedBottomSheetBehavior(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    
      @Override
      public boolean onLayoutChild(final CoordinatorLayout parent, final V child, final int layoutDirection) {
        return super.onLayoutChild(parent, child, layoutDirection);
      }
    
      @Override
      public boolean onInterceptTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) {
        try {
          return super.onInterceptTouchEvent(parent, child, event);
        } catch (NullPointerException ignored) {
          return false;
        }
      }
    }
    

提交回复
热议问题