I tried a lot,but all doesn't work.
I need my date picker the date starts with september 1 2014.But it starts 1900. I set minimum date concept it disappears all past dates. please guys anybody help.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.daty);
click=(ImageView)findViewById(R.id.click);
hdate=(TextView)findViewById(R.id.hdate);
timeStamp = new SimpleDateFormat("dd/MM/yyyy").format(new Date(System.currentTimeMillis()));
hdate.setText(timeStamp);
final Calendar myCalendar = Calendar.getInstance();
final DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
myCalendar.set(Calendar.YEAR, year);
myCalendar.set(Calendar.MONTH, monthOfYear);
myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
click.setVisibility(View.VISIBLE);
updateLabel();
}
private void updateLabel() {
// TODO Auto-generated method stub
String myFormat = "dd/MM/yyyy";
SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
hdate.setText(sdf.format(myCalendar.getTime()));
}
};
hdate.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
DatePickerDialog datePickerDialog = new DatePickerDialog(Daty.this,date, myCalendar
.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
myCalendar.get(Calendar.DAY_OF_MONTH));
datePickerDialog.show();
datePickerDialog.getDatePicker().setMaxDate(System.currentTimeMillis());
}
});
click.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent in=new Intent(Daty.this,Mainy.class);
startActivity(in);
}
});
}
}