title: Inflating a xml layout in a custom View class
body: <p>I have a class <code>View1</code> that extends <code>View</code>. I want to inflate <code>R.layout.test2.xml</code> in this class <code>View1</code>. I have put a following code in this class </p>
  
  <pre><code>public class View1 extends View {
  
      View view;
      String[] countries = new String[] {"India", "USA", "Canada"};
  
      public View1( Context context) {
          super(context);
          LayoutInflater  mInflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          view=mInflater.inflate(R.layout.test2, null, false);
      }
  }
  </code></pre>
  
  <p>From another class <code>Home</code> I want this inflated view to be there for some circumstances , In the <code>Home</code> class I wrote the following code:</p>
  
  <pre><code>public class Home extends Activity{
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.home);
          CreateView();   
      }
  
      public void CreateView() {
          LinearLayout lv=(LinearLayout)findViewById(R.id.linearlayout);
          View1 view = new View1(Home.this);
          lv.addView(view);
      }
  }
  </code></pre>
  
  <p>But as I run my project the activity doesn't show me anything.</p>