Re: How to nest XML layout files??

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Postby selmi » Tue Mar 18, 2008 8:00 pm

mostly it works on same places it doesn't. always this problem with width. so far i gave up and i use nesting where it works and copypaste content everywhere else

it seems that what causes problems is situation where ViewWarpper is part of horizontal vertical layout and this is part of vertical linear layout. then if any of these layouts is taken away it will start to work, but of course screen layout is not as it should be so itsnot solution. i will play with it when i will not have to hurry with other things
selmi
Freshman
Freshman
 
Posts: 7
Joined: Wed Mar 05, 2008 4:49 am
Location: Košice, Slovakia

Top

Postby chitgoks » Wed Mar 19, 2008 2:01 am

in my case, the contents are within a linearlayout which is in a tablelayout

but i tried to simple have blank xml files and each containing a textviwe, while the other xml file imports the other (containing only the textview) and i also get the same error (layout_width)

google should have included nested xml capabilities before android was released, tsk. we cant have all components in 1 xml file.
Website/Java Games: http://www.chitgoks.com
Blogs:
http://tech.chitgoks.com
http://wuhtevah.chitgoks.com
http://disneyusa.blogspot.com
chitgoks
Developer
Developer
 
Posts: 36
Joined: Tue Mar 11, 2008 3:06 am

Postby chitgoks » Wed Mar 19, 2008 3:20 am

hi selmi
i actually got it to work now

what i did was that in my main xml file, i placed a layout, e.g. linearlayout

then in my code

http://tech.chitgoks.com/2008/03/19/and ... g-runtime/


of course you can delete the existing view if you want before calling addView()

ll.removeAllViewsInLayout();

i removed mine because if i kept on adding Views my app will become heavy sooner or later. so we just create new views and leave it to the garbage collector to clean up the removed views

fyi
Last edited by chitgoks on Thu Mar 19, 2009 7:26 am, edited 1 time in total.
Website/Java Games: http://www.chitgoks.com
Blogs:
http://tech.chitgoks.com
http://wuhtevah.chitgoks.com
http://disneyusa.blogspot.com
chitgoks
Developer
Developer
 
Posts: 36
Joined: Tue Mar 11, 2008 3:06 am

Postby Greg_G » Tue Apr 01, 2008 4:22 am

I too am getting the "java.lang.RuntimeException: Binary XML file line #32: You must supply a layout_width attribute." exception. Unfortunately, I'm not just looking to simply nest XML, but to make a custom widget extending LinearLayout with its own behavior that I can use in various places in my app. For that situation, chitgoks' solution doesn't really help.

When I load my custom class from a test Dialog that loads an XML layout which contains the custom class, it loads just fine. But when I load it from a rather complex activity with lots and lots of layout levels, it pops the exception.

I just can't figure it out.
Greg_G
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Apr 01, 2008 4:07 am

Postby selmi » Fri Apr 04, 2008 12:24 am

hi chitgoks
sorry for so late answer, your advise works great, thanks a lot!
selmi
Freshman
Freshman
 
Posts: 7
Joined: Wed Mar 05, 2008 4:49 am
Location: Košice, Slovakia

Postby chitgoks » Thu Mar 19, 2009 7:24 am

this is an old thread. but i just realized that the urls in my signature are old urls. i already have my own domain. so you can surf for my android links in my tech blog. check my signature belowrealized
Website/Java Games: http://www.chitgoks.com
Blogs:
http://tech.chitgoks.com
http://wuhtevah.chitgoks.com
http://disneyusa.blogspot.com
chitgoks
Developer
Developer
 
Posts: 36
Joined: Tue Mar 11, 2008 3:06 am

Top
Previous

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 5 guests