BIT-101 [2003-2017]

Syntax


Doing some Android dev these days. Needed to check if a editable text field was empty or not. I had to dig around to find out how to do this. It turns out that an EditText’s getText() method returns an instance of Editable. You need to convert this to a string and then call equals("") on it. So you get this:

[php lang=“Java”]if(myText.getText().toString().equals("")) {…}[/php]

The similar thing in Objective-C would be:

[php lang=“C”]if([[myText text] isEqualToString:@""]) {…}[/php]

And in ActionScript:

[php lang=“AS3″]if(myText.text == “”) {…}[/php]

I’m going to hold my tongue here, and let you make your own judgments. But as a person who created MinimalComponents, I bet you can guess where my preference lies. 😉

« Previous Post
Next Post »