skydoves / PowerMenu

:fire: Powerful and modernized popup menu with fully customizable animations.
Apache License 2.0
1.19k stars 175 forks source link

Error when trying to use the library #10

Closed NateZ7 closed 6 years ago

NateZ7 commented 6 years ago

The library looks fantastic and I would like to use it. I added the following to the build.gradle

implementation 'com.github.skydoves:powermenu:2.0.3

on onCreate I have the following code -

         powerMenu = new PowerMenu.Builder(this)
                .addItem(new PowerMenuItem("Settings", false))
                .addItem(new PowerMenuItem("Travel", false))
                .addItem(new PowerMenuItem("Logout", false))
                .setAnimation(MenuAnimation.SHOWUP_TOP_LEFT) // Animation start point (TOP | LEFT)
                .setMenuRadius(0f)
                .setMenuShadow(0f)
                .setTextColor(Color.BLACK)
                .setSelectedTextColor(Color.WHITE)
                .setMenuColor(Color.WHITE)
                .setSelectedMenuColor(Color.BLACK)
                .setOnMenuItemClickListener(new OnMenuItemClickListener<PowerMenuItem>() {
                    @Override
                    public void onItemClick(int position, PowerMenuItem item) {
                        Toast.makeText(getBaseContext(), item.getTitle(), Toast.LENGTH_SHORT).show();
                    }
                })
                .build();

        mMenuButton = (Button)findViewById(R.id.floating_menu_context);
        mMenuButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                powerMenu.showAsDropDown(view);
            }
        });

I get the following error :

Error:(339, 26) error: cannot access LifecycleObserver class file for android.arch.lifecycle.LifecycleObserver not found

any help ? thanks !

skydoves commented 6 years ago

Make sure you have these added as gradle dependencies please.

 implementation "android.arch.lifecycle:livedata:1.1.1"
 implementation "android.arch.lifecycle:extensions:1.1.1"

Thanks!

NateZ7 commented 6 years ago

@skydoves Thanks !! It did the trick.

Another question, how do I change the font of the items inside the menu ? Thanks, looks great so far.

skydoves commented 6 years ago

@NateZ7 If you want other fonts of the item, you should use CustomPowerMenu with your own customized item layout.

Thanks!

NateZ7 commented 6 years ago

@skydoves Isn't there any simpler way of doing so instead of creating custom class and adapter ? Thanks !

skydoves commented 6 years ago

@NateZ7 Sorry. The only way is Customizing now. Thank you!

NateZ7 commented 6 years ago

OK, I managed to do what I needed with the CustomPowerMenu, thanks for all the help, great lib !