Sam-In-TechValens
Sam-In-TechValens

Reputation: 2519

fix the value limit of the EditText in Android?

I am working on an application in which I have added an EditField for which the value is fixed for $72.

I have implemented the check at the end of the form but this is not working for me. I need to check this at run-time to check weather user is entering the amount is greater or less then &72.

The value can be in decimal also.

Please suggest me, how can I fix the limit of the EditField to $75.

Upvotes: 3

Views: 1884

Answers (1)

Atif Farrukh
Atif Farrukh

Reputation: 2261

try the following. It will check for the values as soon as the user changes the focus from the EditText

EditText et = (EditText) findViewById(R.id.your_edittext);

et .setOnFocusChangeListener(new OnFocusChangeListener() {

            @Override
            public void onFocusChange(View view, boolean hasFocus) {
                // TODO Auto-generated method stub
                if (!hasFocus) {
                    // Make your loginc here
                } 
            }
        });

Upvotes: 0

Related Questions