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?
Please compare string value not with ==
but equals()
:
String yourString = ;
if (marketValHigh.getText().toString().equals(""))
{
// This should work!
}
This will check if the edit text is empty or not:
if (marketValLow.getText().toString().trim().equals(""))
{
}
Rather what you can check is like:
String text = mSearchText.getText().toString();
if (!TextUtils.isEmpty( mSearchText.getText().trim())) {
// your code
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With