Choose color from Spinner in Settings and set MainActivity background color

0

I have a problem with setting background color via Spinner that is in Settings Activity. Can someone help me? App doesn't crush, but also it don't change color.

I tried a lot of solutions, but none works for me...

Here is my Save button from SettingsActivity


String color = spinnerColor.getSelectedItem().toString();

                View view = findViewById( R.id.list );
                View root = view.getRootView();

                if (color == "Red")
                {
                    root.setBackgroundColor(0x11001100);
                }
                else if (color == "Green")
                {
                    root.setBackgroundColor(0x01000100);
                }
                else if (color == "Blue")
                {
                    root.setBackgroundColor(0x00000001);
                }
                else
                {
                    root.setBackgroundColor(0x16762880);
                }

I expect to change color when button in Settings is pressed, but nothing happens.

android
spinner
asked on Stack Overflow May 9, 2019 by zokistone • edited May 10, 2019 by Zoe

1 Answer

0

I used wrong compare action, this is correct:

 if (color.equals("Red"))
answered on Stack Overflow May 10, 2019 by zokistone

User contributions licensed under CC BY-SA 3.0