title: How can I add a view to an acvity from another class in android?
body: <blockquote>
    <p>Need add view component in android parent layout from another class Xamarin. Following way did tried but not able to create view component without context. </p>
  </blockquote>
  
  <pre><code>/// &lt;summary&gt;
  /// Second activity is intended to have a layout which will populated by another class 
  /// &lt;/summary&gt;
  public class SecondActivity : Activity
  {
  
      private LinearLayout homeScreenLinearLayout;
  
      protected override void OnCreate (Bundle bundle)
      {
          base.OnCreate (bundle);
  
          // Create your application here
          homeScreenLinearLayout = new LinearLayout(this);
          homeScreenLinearLayout.Orientation = Orientation.Vertical;
  
          AddCompeonent ObjAddComponent = new AddCompeonent ();
  
          //The method returns the populated view
          View populatedParentView = ObjAddComponent.AddedView (homeScreenLinearLayout);
          //Show the view generated by add component class
          SetContentView(homeScreenLinearLayout);
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>public class AddCompeonent
  {
      private TextView homeScreenTextView;
      public View AddedView(View parentView){
  
          LinearLayout homeLayout =(LinearLayout) parentView;
          //Create textview here
          homeScreenTextView = new TextView (this);
          homeScreenTextView.Text = "here you will load home screen";
          //Add it to the layout
          homeLayout.AddView (homeScreenTextView);
          return homeLayout;
      }
  }
  </code></pre>