LayoutInflater inflater = (LayoutInflater) Context.GetSystemService(Context.LayoutInflaterService); View view = inflater.Inflate(Resource.Layout.my_layout_file, container, false); container.AddView(view);
ViewGroup layout = FindViewByIdIn this example, we first retrieve the container ViewGroup using its ID. We then get the LayoutInflater object from the current context, and use it to inflate the XML layout file "my_layout_file" into the container ViewGroup. We also specify that the inflated View should be attached to the container ViewGroup. The package library used in these examples is Android.Views.(Resource.Id.my_layout); LayoutInflater inflater = LayoutInflater.FromContext(this); View view = inflater.Inflate(Resource.Layout.my_layout_file, layout, true);