FloatingActionButtonSpeedDial icon indicating copy to clipboard operation
FloatingActionButtonSpeedDial copied to clipboard

disable menu item

Open joey-harward opened this issue 7 years ago • 6 comments

Is there an easy way to disable a particular menu item? I see you can remove and replace, but it would be nice to disable menu items (still show them, but semi-transparent). For instance, I may want to disable an item temporarily until a feature is available. Thanks!

joey-harward avatar Aug 06 '18 12:08 joey-harward

Hi @joey-harward, unfortunately there is no such feature but probably you can achieve this manually setting the alpha after creating the item:

FabWithLabelView fabWithLabelView = mSpeedDialView.addActionItem(new SpeedDialActionItem.Builder(R.id.fab_custom_color, drawable).create());
fabWithLabelView.setAlpha(0.6f);

I cannot test this right now but if you try, please let me know if works or not.

leinardi avatar Aug 06 '18 12:08 leinardi

Thank you for responding, but that does not seem to work. I am using version 1.0.2 and addActionItem returns void so I can't set alpha :)

joey-harward avatar Aug 06 '18 14:08 joey-harward

Oh right, sorry about that. Then I guess you can still do it using findViewById() and the id of the action:

FabWithLabelView fabWithLabelView = mSpeedDialView.addActionItem(new SpeedDialActionItem.Builder(R.id.fab_custom_color, drawable).create());
findViewById(R.id.fab_custom_color).setAlpha(0.6f)

leinardi avatar Aug 06 '18 15:08 leinardi

Yes, that does change the transparency and give the "appearance" of being disabled. Thanks.

I was hoping, however, to be able to disable it using the menu item parameter (android:enabled="false"). This would not only set it semitransparent but disable click handling for that item.

Not a bug really, more of a feature request ;)

joey-harward avatar Aug 07 '18 14:08 joey-harward

Sure I will add it to my to do list :+1:

leinardi avatar Aug 07 '18 15:08 leinardi

This issue has been automatically marked as stale because it has not had activity in the last 60 days.

stale[bot] avatar Oct 06 '18 16:10 stale[bot]