Words in quotation marks ("apple", "bread", "cheese") are underlined by a red wavy line! How to fix?
public void switchButton(Button button) { switch (button.getText()) { case "apple": //ΡΠ»ΠΎΠ²Π° Π² ΠΊΠ°Π²ΡΡΠΊΠ°Ρ
("apple", "bread", "cheese") ΠΏΠΎΠ΄ΡΠ΅ΡΠΊΠ½ΡΡΠ° ΠΊΡΠ°ΡΠ½ΠΎΠΉ Π²ΠΎΠ»Π½ΠΈΡΡΠΎΠΉ Π»ΠΈΠ½ΠΈΠ΅ΠΉ!!! ΠΠ°ΠΊ ΠΈΡΠΏΡΠ°Π²ΠΈΡΡ? button.setBackground(getResources().getDrawable(R.drawable.apple)); break; case "bread": button.setBackground(getResources().getDrawable(R.drawable.bread)); break; case "cheese": button.setBackground(getResources().getDrawable(R.drawable.cheese)); break; } } And used
Button button1, button2, button3; button1 = (Button)findViewById(R.id.button1); button2 = (Button)findViewById(R.id.button2); button3 = (Button)findViewById(R.id.button3); switchButton(button1); switchButton(button2); switchButton(button3);
switch (button.getText()) {replace with thisswitch (button.getText().toString()) {. secondly, here is the stringandroid.util.Log.v("", "string=" + button.getText().toString());insert beforeswitch (button.getText().toString()) {. Now open the logs and findstring=...tell me what is written. - nick