I've implemented an android screen with an Edittext. When the user touches this EditText, a datepickerdialog appears. This all worked fine, however my problem is that when the user touches the EditText, two datepickerdialogs are appearing. I only want one to appear.
I' wondering if anyone has encountered this problem, or is it only me? If yes, are there any solutions? I Google'd it, however found nothing :/
With regards to code, this is what I have:
datebox = (TextView)findViewById(R.id.datebox);
datebox.setOnTouchListener(new OnTouchListener()
{
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
timedatedialog(false);
return false;
}});
public void timedatedialog(boolean flag) {
if(flag==false){
DatePickerDialog dateDlg = new DatePickerDialog(this,
new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth)
{
Time chosenDate = new Time();
chosenDate.set(dayOfMonth, monthOfYear, year);
long dtDob = chosenDate.toMillis(true);
CharSequence strDate = DateFormat.format("MMMM dd, yyyy", dtDob);
Toast.makeText(ForecastingActivity.this,
"Date picked: " + strDate, Toast.LENGTH_SHORT).show();
datebox.setText(strDate);
}}, 2012,0, 1);
Any help is much appreciated. Thanks!