0

if else ステートメントに問題がありました。サポートしてください

if (btn1.getText().toString().equals(myString[6]) &&            
                    (btn1.getText().toString().equals(myString[6]) || (btn1.getText().toString().equals(myString[7]) || (btn1.getText().toString().equals(myString[8]) || (btn1.getText().toString().equals(myString[9]) || (btn1.getText().toString().equals(myString[10]) || (btn1.getText().toString().equals(myString[11]) || (btn1.getText().toString().equals(myString[12]) || (btn1.getText().toString().equals(myString[13]) || (btn1.getText().toString().equals(myString[14]) || (btn1.getText().toString().equals(myString[15])|| 
                            (btn2.getText().toString().equals(myString[6]) || (btn2.getText().toString().equals(myString[7]) || (btn2.getText().toString().equals(myString[8]) || (btn2.getText().toString().equals(myString[9]) || (btn2.getText().toString().equals(myString[10]) || (btn2.getText().toString().equals(myString[11]) || (btn2.getText().toString().equals(myString[12]) || (btn2.getText().toString().equals(myString[13]) || (btn2.getText().toString().equals(myString[14]) || (btn2.getText().toString().equals(myString[15])|| 
                                    (btn3.getText().toString().equals(myString[6]) || (btn3.getText().toString().equals(myString[7]) || (btn3.getText().toString().equals(myString[8]) || (btn3.getText().toString().equals(myString[9]) || (btn3.getText().toString().equals(myString[10]) || (btn3.getText().toString().equals(myString[11]) || (btn3.getText().toString().equals(myString[12]) || (btn3.getText().toString().equals(myString[13]) || (btn3.getText().toString().equals(myString[14]) || (btn3.getText().toString().equals(myString[15])|| 
                                            (btn4.getText().toString().equals(myString[6]) || (btn4.getText().toString().equals(myString[7]) || (btn4.getText().toString().equals(myString[8]) || (btn4.getText().toString().equals(myString[9]) || (btn4.getText().toString().equals(myString[10]) || (btn4.getText().toString().equals(myString[11]) || (btn4.getText().toString().equals(myString[12]) || (btn4.getText().toString().equals(myString[13]) || (btn4.getText().toString().equals(myString[14]) || (btn4.getText().toString().equals(myString[15])|| 
                                                    (btn5.getText().toString().equals(myString[6]) || (btn5.getText().toString().equals(myString[7]) || (btn5.getText().toString().equals(myString[8]) || (btn5.getText().toString().equals(myString[9]) || (btn5.getText().toString().equals(myString[10]) || (btn5.getText().toString().equals(myString[11]) || (btn5.getText().toString().equals(myString[12]) || (btn5.getText().toString().equals(myString[13]) || (btn5.getText().toString().equals(myString[14]) || (btn5.getText().toString().equals(myString[15])|| 
                                                            (btn01.getText().toString().equals(myString[6]) || (btn01.getText().toString().equals(myString[7]) || (btn01.getText().toString().equals(myString[8]) || (btn01.getText().toString().equals(myString[9]) || (btn01.getText().toString().equals(myString[10]) || (btn01.getText().toString().equals(myString[11]) || (btn01.getText().toString().equals(myString[12]) || (btn01.getText().toString().equals(myString[13]) || (btn01.getText().toString().equals(myString[14]) || (btn01.getText().toString().equals(myString[15]) 


                    )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
            {
            Toast.makeText(getBaseContext(), "something wrong", Toast.LENGTH_SHORT).show();          
            } 

            else if (btn1.getText().toString() == (btn2.getText().toString())
                (btn1.getText().toString() == (btn3.getText().toString())||
                        (btn1.getText().toString() == (btn4.getText().toString())||
                                (btn1.getText().toString() == (btn5.getText().toString())||
                                        (btn1.getText().toString() == (btn01.getText().toString())||
                                                (btn2.getText().toString() == (btn3.getText().toString())||
                                                        (btn2.getText().toString() == (btn4.getText().toString())||
                                                                (btn2.getText().toString() == (btn5.getText().toString())||
                                                                        (btn2.getText().toString() == (btn01.getText().toString())||
                                                                                (btn3.getText().toString() == (btn4.getText().toString())||
                                                                                        (btn3.getText().toString() == (btn5.getText().toString())||
                                                                                                (btn3.getText().toString() == (btn01.getText().toString())||
                                                                                                        (btn4.getText().toString() == (btn5.getText().toString())||
                                                                                                                (btn4.getText().toString() == (btn01.getText().toString())||
                                                                                                                        (btn5.getText().toString() == (btn01.getText().toString()))))))))))))))))
            {
                Toast.makeText(getBaseContext(), "something same", Toast.LENGTH_SHORT).show();           
            }
            else (btn1.getText().toString().equals(myString[0])||
                    (btn1.getText().toString().equals(myString[1])||(btn1.getText().toString().equals(myString[2])||(btn1.getText().toString().equals(myString[3])||(btn1.getText().toString().equals(myString[4])||(btn1.getText().toString().equals(myString[5])))))))
            {
                Toast.makeText(getBaseContext(), "test", Toast.LENGTH_SHORT).show();
            }
        }

ステートメントが実行された場合、「同じもの」のみが表示されます。上記のコードから何を追加すればよいですか?

4

1 に答える 1

3

最初....else if (btn1.getText().toString() == (btn2.getText().toString())....

String を比較するために使用.equals()し、else if の代わりに ledder を使用すると、いくつかの問題を確認できます...

于 2012-04-23T04:09:39.657 に答える