Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Why XML to define layouts/components?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Expand all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Casper Bang  
View profile  
 More options Aug 6, 12:29 pm
From: Casper Bang <casper.b...@gmail.com>
Date: Thu, 6 Aug 2009 09:29:48 -0700 (PDT)
Local: Thurs, Aug 6 2009 12:29 pm
Subject: Why XML to define layouts/components?
My original first post doesn't seem to get approved, so let me try
again. :)

I'm wondering whether other Android newbies than me find the empathy
on XML layout troublesome? I realize we should strive to separate view
from logic and that XML is hip and trendy, but is it really necessary
for these relatively simple Android applications?

XML layouts involves more files and what feels like a lot of
"magic" (type unsafe) properties, and makes samples harder to follow/
type. It also can't be especially efficient to use findViewById
(whether BFS or DFS based) constantly?

It sort of reminds me of the differences between JSF and Wicket, where
the former was designed by people sitting in an ivory tower while the
latter was designed for and by people at the ground, comfortable with
Java. Which also leads me to wonder how come Android uses the old type-
unsafe int enum pattern and also, why fluent-interfaces/method-
chaining isn't used in greater extend?

/Casper

PS: You might want to fix the URL's to the group charter and FAQ as
they currently go into 404.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Teal  
View profile  
 More options Aug 6, 7:25 pm
From: Teal <teal.b...@gmail.com>
Date: Thu, 6 Aug 2009 16:25:47 -0700 (PDT)
Local: Thurs, Aug 6 2009 7:25 pm
Subject: Re: Why XML to define layouts/components?
You can construct the UI programatically without using XML.  Follow
the Hello World tutorial (http://developer.android.com/guide/tutorials/
hello-world.html), and note how the UI is constructed in "Construct
the UI" section, and notice how it is alternatively implemented using
XML in the "Upgrade the UI to an XML Layout" section.

On Aug 6, 12:29 pm, Casper Bang <casper.b...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yusuf T. Mobile  
View profile  
 More options Aug 7, 5:25 pm
From: "Yusuf T. Mobile" <Yusuf.S...@T-Mobile.com>
Date: Fri, 7 Aug 2009 14:25:35 -0700 (PDT)
Local: Fri, Aug 7 2009 5:25 pm
Subject: Re: Why XML to define layouts/components?
If your question is "why even use XML to layout UI?" the answer is
"because some people like it better; they find it easier and cleaner;
other's prefer to do it in Java". As Teal said, you don't have to use
XML if you don't like. I at first found the XML layout method foreign,
and the plethora of approaches daunting. I would have benefitted from
a tutorial that first focused on only Java and then broadened to XML,
but I survived and now find XML UI layout to be useful, sometimes.

Yusuf Saib
Android
·T· · ·Mobile· stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.

On Aug 6, 4:25 pm, Teal <teal.b...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Casper Bang  
View profile  
 More options Aug 7, 5:55 pm
From: Casper Bang <casper.b...@gmail.com>
Date: Fri, 7 Aug 2009 14:55:16 -0700 (PDT)
Local: Fri, Aug 7 2009 5:55 pm
Subject: Re: Why XML to define layouts/components?
Exactly my point, it seems like it would be easier to learn Android
that way. It wasn't until I found Mark Murphy's "The Busy Coder's
Guide to Android Development" that I starting feeling a bit more
comfortable with all the XML (lots of examples gradually introduced,
unlike the O'Reilly and Manning books I have).

Also, Roman Guy replied in another thread, that you can't do the same
with Java as you can with XML (although that seems odd, all other XML
view technologies I know of ultimately translates into a Java
component tree):
http://groups.google.com/group/android-beginners/browse_thread/thread...

/Casper

On 7 Aug., 23:25, "Yusuf T. Mobile" <Yusuf.S...@T-Mobile.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Romain Guy  
View profile  
 More options Aug 7, 6:00 pm
From: Romain Guy <romain...@google.com>
Date: Fri, 7 Aug 2009 15:00:15 -0700
Local: Fri, Aug 7 2009 6:00 pm
Subject: Re: [android-beginners] Re: Why XML to define layouts/components?

> Also, Roman Guy replied in another thread, that you can't do the same
> with Java as you can with XML (although that seems odd, all other XML
> view technologies I know of ultimately translates into a Java
> component tree):
> http://groups.google.com/group/android-beginners/browse_thread/thread...

You can do the same, but with XML the system will automatically select
the appropriate layout based on the device's configuration. You could
do it by hand if you really wanted but have fun with that. There is
really very little point in building the UI from Java code except
complicating the source code and making some things harder (like
supporting configurations.)

--
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Murphy  
View profile  
 More options Aug 7, 6:12 pm
From: Mark Murphy <mmur...@commonsware.com>
Date: Fri, 07 Aug 2009 18:12:42 -0400
Local: Fri, Aug 7 2009 6:12 pm
Subject: Re: [android-beginners] Re: Why XML to define layouts/components?

Casper Bang wrote:
> It wasn't until I found Mark Murphy's "The Busy Coder's
> Guide to Android Development" that I starting feeling a bit more
> comfortable with all the XML

That is due to the subliminal "angle brackets are your friends" I have
in the watermark on the pages.

;-)

> Also, Roman Guy replied in another thread, that you can't do the same
> with Java as you can with XML (although that seems odd, all other XML
> view technologies I know of ultimately translates into a Java
> component tree):
> http://groups.google.com/group/android-beginners/browse_thread/thread...

His second post was a bit confusing to me, but I think he was trying to
echo the point he tried to emphasize in his first post.

When you get to the Resources chapter in the aforementioned book,
there's a section at the end that covers resource sets. Those allow you
to have different resources loaded based on different criteria, from
user language to screen resolution to the existence of a QWERTY
keyboard, and beyond. While it is technically possible to do all of that
in Java, you'll drown in a sea of if(), switch(), and ternary operators.

Similarly, while it is technically possible to use containers like
RelativeLayout fully in Java, it is *much* more verbose than setting
them up in XML.

Finally, one key reason why any development platform uses XML for
anything is to help support the creation of tools to manipulate it.
Admittedly, that hasn't happened much with Android, outside of the main
SDK tools and stuff like MOTODEV's extensions on the same. But it is
much easier to build tools to generate and modify XML-based UIs than it
is to build tools to generate and modify Java-based UIs, IMHO.

Those sorts of arguments may not matter much to you, which is why the
Java-based approach is available and valid. I use it sometimes myself,
though not terribly often. Choose the approach that you like.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android App Developer Books: http://commonsware.com/books.html


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Casper Bang  
View profile  
 More options Aug 7, 7:37 pm
From: Casper Bang <casper.b...@gmail.com>
Date: Fri, 7 Aug 2009 16:37:23 -0700 (PDT)
Local: Fri, Aug 7 2009 7:37 pm
Subject: Re: Why XML to define layouts/components?
Thanks guys, I now understand the empathy on XML a little better. :)

/Casper

On 8 Aug., 00:12, Mark Murphy <mmur...@commonsware.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google