Kennyc1012 / BottomSheetMenu

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

hey #52

Closed tomridder closed 6 years ago

tomridder commented 6 years ago

i want to setListener event for each item on the Sheet how to write it ?thank u !

Kennyc1012 commented 6 years ago

Add a BottomShretListener to the dialog and use the onSheetItemSelected to handle the different items

tomridder commented 6 years ago
            BottomSheetListener bsl=new BottomSheetListener()
            {
                @Override
                public void onSheetShown(@NonNull BottomSheet bottomSheet, @Nullable Object o)
                {

                }

                @Override
                public void onSheetItemSelected(@NonNull BottomSheet bottomSheet, MenuItem menuItem, @Nullable Object o)
                {
                    Toast.makeText(ShowNote.this,"onSheetItemSelected",Toast.LENGTH_SHORT).show();
                               if(menuItem.getTitle().equals("wechat"))
                               {
                                   Toast.makeText(ShowNote.this,"wechat",Toast.LENGTH_SHORT).show();
                               }
                    if(menuItem.getTitle().equals("qq"))
                    {
                        Toast.makeText(ShowNote.this,"qq",Toast.LENGTH_SHORT).show();
                    }
                    if(menuItem.getTitle().equals("friendCycle"))
                    {
                        Toast.makeText(ShowNote.this,"friendCycle",Toast.LENGTH_SHORT).show();
                    }
                }

that's what i am doing right now,is that correct to setListener for each Item??

Kennyc1012 commented 6 years ago

You'll need to set the listener for every dialog you have created. See the sample app for an example

tomridder commented 6 years ago

well ,can u copy this part of code for me ?i have seen your source code,but i didn't find that part...

tomridder commented 6 years ago

this is my email 1402709211@qq.com

Kennyc1012 commented 6 years ago

https://github.com/Kennyc1012/BottomSheet/blob/master/sample/src/main/java/com/kennyc/bottomsheetsample/MainActivity.java

tomridder commented 6 years ago

well,there's only two lines of code for that @Override public void onSheetItemSelected(@NonNull BottomSheet bottomSheet, MenuItem item, @Nullable Object object) { Toast.makeText(getApplicationContext(), item.getTitle() + " Clicked", Toast.LENGTH_SHORT).show(); } but i want to see the detail of setListener for each Item

tomridder commented 6 years ago

my code is right ,thanks for talking with me

Kennyc1012 commented 6 years ago

I'm not sure what you are asking or trying to achieve. If you want to receive a call back when an item is selected from the sheet you set a listener and handle the MenuItem in the onSheetItemSelected callback