skydoves / PowerMenu

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

is this allow to create single selection popup menu #71

Closed Miteshmakwana73 closed 3 years ago

Miteshmakwana73 commented 3 years ago

i want to create popup menu with radio button is it possible?

image_2021_04_29T07_34_07_694Z

skydoves commented 3 years ago

You can resolve this using a customized popup.

Miteshmakwana73 commented 3 years ago

i'll try this

Miteshmakwana73 commented 3 years ago

@skydoves

I pass selecter file but it's not working only changing the text color only not changing drawable

public static PowerMenu getIconPowerMenu(
      Context context,
      LifecycleOwner lifecycleOwner,
      OnMenuItemClickListener<PowerMenuItem> onMenuItemClickListener) {

    Context styledContext = new ContextThemeWrapper(context, R.style.PopupCardThemeOverlay);

    return new PowerMenu.Builder(styledContext)
        .addItem(new PowerMenuItem("WeChat", R.drawable.image_selecter))
        .addItem(new PowerMenuItem("Facebook", R.drawable.image_selecter))
        .addItem(new PowerMenuItem("Twitter", R.drawable.image_selecter))
        .addItem(new PowerMenuItem("Line", R.drawable.image_selecter))
        .addItem(new PowerMenuItem("Other", R.drawable.image_selecter))
        .setLifecycleOwner(lifecycleOwner)
        .setOnMenuItemClickListener(onMenuItemClickListener)
        .setAnimation(MenuAnimation.FADE)
        .setMenuRadius(context.getResources().getDimensionPixelSize(R.dimen.menu_corner_radius))
        .setMenuShadow(context.getResources().getDimensionPixelSize(R.dimen.menu_elevation))
        .setIsMaterial(true)
        .build();
  }

selecter file

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/ic_baseline_radio_button_checked_24" android:state_selected="true"></item>
    <item android:drawable="@drawable/ic_baseline_radio_button_unchecked_24" android:state_selected="false"></item>

</selector>

onIconMenuItemClickListener i write this line

iconMenu.setSelectedPosition(position);

device-2021-04-29-181240

this what i got now

skydoves commented 3 years ago

Hi, that will not work correctly, because the icon is not a selectable ImageView. I mean we should create a custom adapter using the MenuBaseAdapter like this.