K
K
Kurban Mammaev2015-03-29 11:56:20
Java
Kurban Mammaev, 2015-03-29 11:56:20

How to check for pressing the "." on the numeric keypad NumberDecimal?

I did the check as follows.

Edittext myedittext = (EditText) findViewById(R.id.edittext1);

if(myedittext.gettext().toString()==".")
 {
      // Действия
}

The check doesn't work.
How can you implement validation? Explain, please. Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timur, 2015-03-29
@Axe98

In Java, string values ​​are not checked for "==" (unlike C#, for example)
. You need to call the .equals() method.

if(myedittext.getText().toString().equals(".")) {
      // Действия
}

PS: If the returned string is longer than one character, then you can check for "." by calling the contains() method.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question