Linked Questions

Popular Questions

Android EditText & Dialogbox

Asked by At

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(;

    datebox.setOnTouchListener(new OnTouchListener() 


        public boolean onTouch(View arg0, MotionEvent arg1) {
            return false;

public void timedatedialog(boolean flag) {


               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);

                        "Date picked: " + strDate, Toast.LENGTH_SHORT).show();


            }}, 2012,0, 1);

Any help is much appreciated. Thanks!

Related Questions