How to check if EditText has a value in Android / Java

Posted by Allen Gingrich on Stack Overflow See other posts from Stack Overflow or by Allen Gingrich
Published on 2010-08-04T13:25:06Z Indexed on 2010/12/23 11:54 UTC
Read the original article Hit count: 223

Filed under:
|

This should be simple, but I have tried if statements checking for null values and also ones checking the .length of it:

EditText marketValLow = (EditText) findViewById(R.id.marketValLow);
            EditText marketValHigh = (EditText) findViewById(R.id.marketValHigh);
            if (marketValLow.getText().length() != 0 && marketValHigh.getText().length() != 0) {
                Intent intent = new Intent();
                intent.setClass(v.getContext(), CurrentlyOwe.class);
                startActivity(intent);
            } else {
                Toast.makeText(CurrentMarketValue.this, "You need to enter a high AND low.", Toast.LENGTH_SHORT);
            }

But it doesn't detect nothing was entered. Any ideas?

Thanks!

© Stack Overflow or respective owner

Related posts about java

Related posts about android