title: How to add relative layout to a View
body: <p>I have a custom Relative Layout and added a button to it </p>
  
  <pre><code> RelativeLayout rel_layout = new RelativeLayout(mcontext);
   RelativeLayout.LayoutParams rel_param = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
   rel.setLayoutParams(rel_param);
  
   Button b = new Button(mcontext);
   RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
   b.setLayoutParams(params);
   b.setText("Test");
   rel_layout.addView(b);
  </code></pre>
  
  <p>Now, I want this Relative layout to be added to a View. My View Class looks like this is</p>
  
  <pre><code>public class CustomView extends View {
  
  Context mcontext;
  
  public CustomView(Context context) {
      super(context);
  
      this.mcontext = context;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and in the Main Activity I am calling this view in my setConentView()</p>
  
  <pre><code>public class MainActivity extends Activity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(new CustomView(this));
  }
  </code></pre>
  
  <p>}</p>
  
  <p>So now on the Screen I should have the relative layout with the button in it. I should not use any XMl's. </p>
  
  <p>I need help in how to add the dynamic relative created to be added to my CustomView class</p>
  
  <p>Hope I have explained my problem clearly.</p>