Write the code given below in onclick any button or clickable widgets and add a linear. than run your project.

DatePicker dp=new DatePicker(MainActivity.this);

linear1.addView(dp);