last day (14 days later) » 

9:47 AM
1
A: Error when generating dynamic content

AtaYou are trying to add the same instance over and over again. Thus the message that "specific child already exists". You would have to create a new template layout instance with different ID (I suppose) and then try to add it in. So rather than: ((RelativeLayout) insertPoint).addView(v1, templat...

 
When I created a new instance in Onclick it generated just the first element and stopped without adding anymore, didn't crash and giving me an error though. When I tried to v1.setId(templateID) and then incrementing "templateID" it spawned the form at the top of the layout, losing where its supposed to be created without creating more than one form.
 
Ata
You are adding in a RelativeLayout. You have to define the position of second item that you add relative to the first item otherwise it will end up on top of first one. Is there any specific need to use relative layout as parent layout or you can use Linear layout as well? Because for linear layout you would just need to add view and it will place it Vertically or Horizontally.
 
Thanks! Its correctly adding several ones when the container is a LinearLayout. Only now its adding the forms at the top of the layout regardless of the fact that I've set it to go below a certain element in my page. Any clue?
 
Ata
You mean that in LinearLayout (as parent), adding new items show them at top of previous one's rather then below? Or is that for RelativeLayout
 
Yeah the LinearLayout is the parent/container, when I add its jumping at the top of the entire page, overlaying other layouts, even though the LinearLayout parent container is set to be below another RelativeLayout in my XML.
 
Ata
9:47 AM
i am unsure about your layouts here. Can you update the question and add the solution thats working now (below the question).
 
Updated the original question.
Hello
 
Ata
Hi,
 
Thanks for helping me out. I just don't get why the called form is jumping at the top of the page.
 
Ata
Can you test your LinearLayout and other RelativeLayout by adding some static templates in questionsContainer
This will check if adding something in questionsContainer mess up the positioning
Just add 2-3 templates with random data in questionsContainer
Np
 
Alright, I just added a button in questionsContainer and it added it correctly, that is below questionTemplateFake
Going to provide a screenshot
And im going to provide screenshots how the layout is originally and when I add the form
 
Ata
9:54 AM
OK, and if you add the templates dynamically (which messes up things) can you send a screenshot of that aswell
 
Yes I'm going to provide those screenshots as well
This is how it looks before I add the form
And this is after I add the forms
 
Ata
I see, one more thing. The static template that you added above (that looks ok in graphical view). can you also run that and see if it's the same at runtime
 
Isnt it the same one that is in the second screenshot?
 
Ata
The very first screenshot where you added a Button in linear layout. If you run that, how does it look like?
 
Ah yes
You're right
When I run it the button appears at the top of the template
 
Ata
10:09 AM
ok, you are doing something at runtime that might be messing up things. Cleanup your code in Initialize(), I suppose you don't need that anymore. And just keep 3 line in the onClick (1- inflate, 2- setId, 3- add to parent)
 
Works! ^^
Thank you very very much! :D
 
Ata
Np.
 
Is there no way for me to switch the parent to a relativeLayout?
 
Ata
You can, but then you will have to things like layout_below etc programatically
and see how things look up at runtime
 
Hmmm alright
I'll try that
 
Ata
10:15 AM
the RelativeLayout.LayoutParam may have the functions you need
 
Alright
Again, thank you very much
 

last day (14 days later) »