I'm new to this forum and wanted to start learning about Xamarin. I was trying to understand how to use a Layout Inflater, i've found a very simple example on youtube(it was for Android tho) and now i'm trying to implement it on Xamarin, i can Build it with no errors, but i just want to make sure if this is a correct way to do it.
I have two files: MainActivity.cs and inside Resources/Layout i have a Sublayout activity.
i want to bind the Sublayout activity(which only has a text view) to the Main Activity, here's my code:
base.OnCreate (bundle); // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); LinearLayout l = FindViewById<LinearLayout>(Resource.Id.myLinearLayout); LayoutInflater inflater = (LayoutInflater)this.GetSystemService (Context.LayoutInflaterService); View v = inflater.Inflate(Resource.Layout.Sublayout, null, false); l.AddView (v); `
I have noticed that i can even delete the creation of the inflater and only do
View v = LayoutInflater.Inflate(Resource.Layout.Sublayout, null, false);