I have a class View1 that extends View. I want to inflate R.layout.test2.xml in this class View1. I have put a following code in this class 
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);
    }
}
From another class Home I want this inflated view to be there for some circumstances , In the Home class I wrote the following 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);
    }
}
But as I run my project the activity doesn't show me anything.
 
     
     
     
     
     
     
     
     
     
    