How to write block for 50 favorite buttons

How to write block for 50 favorite buttons
Action Required: on button click color change from black to red and 2nd time button click set to unfavorite

use if then else block

on click
if the button is red color
then set button color to green
else set button color to red

Thanks for reply, How to write block for 50 favorite button?

use when any button clicked block… no need to write for 50 buttons… this single event will take care of it

How to work with the advanced features

A Multiple Choice Quiz: How to work with the advanced features

Taifun

1 Like

Thanks for reply.Can u help me? screenshot is attached herewith

Action Required: on button click color change from black to red and 2nd time button click set to unfavorite

as it already has been said: use the advanced features…
do the tutorials I mentioned earlier, then try something and if you got stuck, post a screenshot of your relevant blocks

protip: use the Any Button.BackgroundColor property to set the background color of a button component of your choice

Taifun

1 Like

When any button clicked
If background color of clicked button is red
Then set bkgrd clr of button to green/white
Else set bkgrd clr of button to red

Simple. Pls try,

You have not clear us whether they are all ordinary button or dynamically created… if they dynamic button, you must use one more if else

When any button clicked
If IsDynamic componet clicked button
If background color of clicked button is red
Then set bkgrd clr of button to green/white
Else set bkgrd clr of button to red

If they are not dynamic button then you must put all the buttons they are used for favourite into a list
Like initialise favourite button make a list (button1)(button2)…(last button)

Then just add one if condition

When any button clicked
If the component is in the list global buttons
Then-If background color of clicked button is red
Then set bkgrd clr of button to green/white
Else set bkgrd clr of button to red

Suggestion- for your case(50 buttons) You must go with dynamic component…

3 Likes

Thanks for guidance
Please find below my project-related example code.
Action Required: on any favorite button click add to favorite list and button text change from favorite_border to favorite and 2nd time button click set to unfavorite and button text change from favorite to favoriteborder.

example.aia (10.8 KB)

Try this and see if it works for you, using [F/OS] - Dynamic Components Extension (for every component) 2.2.2

example_1.aia (39.7 KB)

1 Like

It does work according to me, @intv2018 you should check it

As i suggest you earlier try dynamic component or else if you want to continue with your exisitng blocks, just test this

example_2.aia (10.5 KB)

if you use more and more buttons, at the time of compiling app, it will refuse to compile into apk… AFter seeing the blocks, just learn how to use when any button clicked event…

1 Like

Thank you for helping me with this project.
Once again Thanks a lot for all of you.!!

1 Like