Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge xml layout programmatically in Android

I have build a layout programmatically in Android (a treeview) and now I'd like to add to the built view a topbar (topbar.xml).

So what I need is instead of:

setContentView(scroll)

Something like:

inflateInMyViewCalledScroll(topbar.xml)
setContentView(scroll)

Thanks for your suggestions

like image 532
Luigi Tiburzi Avatar asked Feb 16 '26 02:02

Luigi Tiburzi


1 Answers

Inflate topbar.xml using LayoutInflater, putting the results into scroll:

getLayoutInflater().inflate(R.layout.topbar, scroll);
like image 189
CommonsWare Avatar answered Feb 18 '26 15:02

CommonsWare



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!