> I would like to know if it is possible to compare two different
> EditTexts using a if...else statement. I am trying to compare them
> with this template:
>
> if(<name>.getText() == <anotherName>.getText()){
> //code
> }
> else {
> //more code
> }
>
> No matter what i always get the else block of code even if i display
> my answer and the correct one and they are obviously the same. Is
> there another comparison method or is my code wrong?
You need to tack a .toString() in there as well:
if(<name>.getText().toString().equals(<anotherName>.getText().toString())){
getText() returns an android.text.Editable object, not a String.
--
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ -- Available Now!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---