Sunday, February 12, 2012

Debugging XML?

Let me quote the Hello World tutorial at

"The general structure of an Android XML layout file is simple: it's a tree of XML elements. ... This structure makes it easy to quickly build up UIs, using a more simple structure and syntax than you would use in a programmatic layout."

Hmm, let's try that. First the xml version:

  android:text="Hello, Android"/>
And now the Java version:

TextView tv = new TextView(this);
tv.setText("Hello, Android");
Is the xml version simpler? Not sure. It's a little bit verbose but still readable.

What about editor support? In a good editor, like that of IntelliJ, I can Ctrl+Space Java code as well as Android layout xml. So, no difference.

But there is one difference:

You can step Java code, but you cannot step XML!

Case closed.


Anonymous said...

well said...

Anonymous said...

+1. Just began my foray into android development and Java coming from other mobile and web-dev backgrounds. Sure enough a syntax error in one of my XML layouts cascaded into an almost untraceable exception. Can't step through notation or markup!