Reputation: 163
I have created some xml layouts. Now I am creating a custom layout (in my java file) with some elements and want to add the previously created layout(xml layouts). How can I do that?
Upvotes: 1
Views: 359
Reputation: 1438
You can use LayoutInflater
to inlate layouts. And add inflated view to your custom view by addView()
method
For ex:
LayoutInflater mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ViewGroup viewTobeLoaded = mInflater.inflate(R.layout.ilan_list_item, null);
yourView.addView(viewTobeLoaded);
Hope helps
Upvotes: 2