0

How to open bottom sheet when clicking menu item | android studio ?

see this pict

btnShow = findViewById(R.id.info);

this is my current code, i use button for item menu -,- :

private Button button;

Button btnShow;

    btnShow.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(
                    Content.this,R.style.BottomSheet
            );
            View bottomSheet = LayoutInflater.from(getApplicationContext())
                    .inflate(R.layout.bottom_sheet_layout,
                            (LinearLayout) findViewById(R.id.bottomSheetCont));
            bottomSheetDialog.setContentView(bottomSheet);
            bottomSheetDialog.show();
            bottomSheet.findViewById(R.id.contLayoutOne).setOnClickListener(new View.OnClickListener(){
                @Override
                public void onClick(View v){
                    Toast.makeText(Content.this, "Option 1", Toast.LENGTH_SHORT).show();
                    bottomSheetDialog.dismiss();
                }
            });
        }
    });

0 Answers0