Using existing xml layouts

108 views
Skip to first unread message

Andrew Richards

unread,
Sep 29, 2014, 2:26:07 PM9/29/14
to mac...@googlegroups.com
Hi,

Is there any way to incorporate existing XML layouts into a larger layout based on tweaks?

Thanks,

Andrew

Nick Stanchenko

unread,
Oct 4, 2014, 7:31:40 PM10/4/14
to mac...@googlegroups.com
Hi,

Sorry for the late reply — I’ve been delivering my thesis :)
Could you elaborate on your use-case? If I understood the question correctly, you can do e.g. this:

l[LinearLayout](
  w
[Button],
 
Ui(layoutInflater.inflate(..., ...))
)

Nick

Andrew Richards

unread,
Oct 5, 2014, 8:22:09 AM10/5/14
to mac...@googlegroups.com
Hi,

Yes that was what I was after. I'd figured something else out with addViews() but this is much better. 

Thanks

wou...@q42.nl

unread,
Mar 27, 2015, 8:28:36 AM3/27/15
to mac...@googlegroups.com
Hi,

I saw this post and this was almost the thing I was looking for. I'm trying to reuse existing layout XML files and want to add On... handlers by using the an EventTweaks.

Is is possible to inflate an XML, add it to the view and then retrieve a widget from this view and apply tweaks to it?

I'm trying to inject the XML and write the On.click {} inline; it compiles, but doesn't work (the otherField is a existing "slot" by-the-way):

val view = l[LinearLayout](
Ui(inflater.inflate(R.layout.test_layout, null))
) <~ vertical

val button = view.find[Button](R.id.button)
button <~ On.click {
otherField <~ text("button clicked")
}

Is it possible to do something like this or is Macroid not available when you added an inflated view?

Thanks in advance!

Gr. Wouter

Nick Stanchenko

unread,
Mar 27, 2015, 8:47:11 AM3/27/15
to wou...@q42.nl, mac...@googlegroups.com
Hi,

By “does not work”, do you mean “nothing happens” or “it crashes” or something else? My first guess would be that you need to enclose your UI action (setting the click handler) into “runUi”.

Nick


--
You received this message because you are subscribed to the Google Groups "macroid" group.
To unsubscribe from this group and stop receiving emails from it, send an email to macroid+u...@googlegroups.com.
To post to this group, send email to mac...@googlegroups.com.
Visit this group at http://groups.google.com/group/macroid.
To view this discussion on the web visit https://groups.google.com/d/msgid/macroid/32c00ea4-8a03-4798-8e5f-c92ccd035627%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages