I am doing an Android Development and I have a doubt in date picker dialog.
When a button is clicked, a date picker pops up and the user should be able to select the date.
The code is successfully compiled, and when I click a button, the dialog pops up as shown in image 1, but I'd like the date picker to be as image 2.
Please let me know where do I have to change the code.
Below is the code:
public class MainActivity extends AppCompatActivity {
Button B1;
int day_x, month_x, year_x;
static final int id=0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
B1 = (Button)findViewById(R.id.button);
B1.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v) {
showDialog(id);
}
});
}
@Override
protected Dialog onCreateDialog(int id1)
{
if (id1==id)
return new DatePickerDialog(MainActivity.this,listener,year_x,month_x,day_x);
return null;
}
protected DatePickerDialog.OnDateSetListener listener
=new DatePickerDialog.OnDateSetListener()
{
public void onDateSet(DatePicker view,int year,int month,int day)
{
year_x=year;
month_x=month;
day_x=day;
Toast.makeText(MainActivity.this,Integer.toString(day_x)+":"+Integer.toString(month_x)+":"+
Integer.toString(year_x),Toast.LENGTH_SHORT).show();
}
};
}

