Kennyc1012 / BottomSheetMenu

BottomSheetMenu style dialogs for Android
Apache License 2.0
887 stars 99 forks source link

Set click listener for customview buttons #50

Closed paramarthasaha96 closed 6 years ago

paramarthasaha96 commented 6 years ago

So i have some buttons in my custom layout which i need to click to do some actions. Is it possible to do it and if yes how?

Kennyc1012 commented 6 years ago

When creating a BottomSheet with a custom view, you can setup the view however you want, for example:

View v = LayoutInflater.from(getContext()).inflate(R.layout.my_view,null);
v.findViewById(R.id.my_button).setOnClickListener(v->doSomething());

new BottomSheet.Builder(this)
    .setView(v)
    .show();

OR you can attach a BottomSheetListener, then in the onSheetShown callback, you can call getLayout on the BottomSheet object passed which will pass the root view of the BottomSheet

paramarthasaha96 commented 6 years ago

Thanks for it closing the issue.