Android BottomSheetDialog消失後再次無法顯示的處理方法
阿新 • • 發佈:2019-01-24
在使用BottomSheetDialog滑動消失後,再次點選顯示的時候,沒有成功顯示,BottomSheetBehavior被設定成了隱藏模式,需要在dismiss()的監聽中重新設定下狀態就可以了
View bottomSheetView = getLayoutInflater().inflate(R.layout.bottomsheetdialog_layout, null); BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(MainActivity.this); bottomSheetDialog.setContentView(bottomSheetView); BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from((View) bottomSheetView.getParent()); bottomSheetDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); textPrompt1.setText("OnDismiss"); } });