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.
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:
> 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.
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:
> 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:
> > 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.
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:
> 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:
> > 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:
> > > 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.
> 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.)
> On 7 Aug., 23:25, "Yusuf T. Mobile" <Yusuf.S...@T-Mobile.com> wrote:
>> 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:
>> > 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:
>> > > 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.
-- 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
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.
> 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.