faboptions icon indicating copy to clipboard operation
faboptions copied to clipboard

Menu icons or menu can't be changed programmatically

Open abduldblogger opened this issue 6 years ago • 8 comments

First of all, thanks for making this fabulous library!

I am using version 1.2.0 and facing some issues:

  1. There is no method to change menu icons programmatically.
  2. When I tried to overcome this issue by using 2 different menus which hold different icons, I was able to change menu, but UI was distorted.

menu opened first time menu opened after menu changed

I want to use menus to make an article favorite/ unfavourite, and then according to user input want to change status (icon) of the menu.

Thanks and Regards, Abdul Aziz Ansari

abduldblogger avatar Dec 03 '18 13:12 abduldblogger

Hey @abduldblogger,

Thanks for the detailed issue. Have you tried to use a selector instead? You are right I haven't made it possible to change the icons at runtime, but I'm pretty sure you can accomplish this that way ;).

JoaquimLey avatar Dec 05 '18 09:12 JoaquimLey

Hi @JoaquimLey,

thanks for replying, sorry I can't get it, how to use "selector", can you show some demo?

abduldblogger avatar Dec 07 '18 07:12 abduldblogger

You can google that :)

  • https://developer.android.com/guide/topics/resources/color-list-resource

JoaquimLey avatar Dec 07 '18 07:12 JoaquimLey

ohh, got it, but that is basically used for buttons, that has some states, like focused, pressed, default etc, but how in menu? , I have 2 states only, either favorite or unfavorite, hence I have to used 2 different images (heart image), I hope you understood the issue...

abduldblogger avatar Dec 07 '18 08:12 abduldblogger

Yes it is possible hehe :)

  • https://stackoverflow.com/a/23795983/3374428

JoaquimLey avatar Dec 13 '18 12:12 JoaquimLey

@abduldblogger Do you think I can close this issue?

JoaquimLey avatar Dec 13 '18 13:12 JoaquimLey

@JoaquimLey , that solution is when you press any menu item and then release, so you will see default and pressed state (different icons for example), for the moment when your thumb is on the menu, but afterward it will come back to normal on removing the touch, what I want to achieve is after pressing the menu item, change the menu icon permanently...I hope I am able to explain you

For better understanding, this will be the change change icon in menu:

screenshot_1544707128

abduldblogger avatar Dec 13 '18 13:12 abduldblogger

Have you tried the solution with the selectors?

JoaquimLey avatar Jan 22 '19 12:01 JoaquimLey