[Solved] getText().toString().trim().length() == 4 not working


Since you are just checking if your EditText has string or not, why dont you use.

if(mSwitcher.getText().toString().isEmpty())
{
....
...
}

More over it becomes

if (mSwitcher.getText().toString().isEmpty()) {
        final Button button2 = (Button) findViewById(R.id.button2);
        final Animation buttonz = new AlphaAnimation(0.0f, 1.0f);
        buttonz.setDuration(3000);
        button2.startAnimation(buttonz);
    } else {


    }

I do not recommend to use

final Button button2 = (Button) findViewById(R.id.button2);
final Animation buttonz = new AlphaAnimation(0.0f, 1.0f);

inside if statement.

BTW is mSwitcher an EditText ??

According to the known new requirement.

if(mSwitcher.getText().length()!=4)
{
    myButton.setEnabled(false);//change to your button name
}

6

solved getText().toString().trim().length() == 4 not working