Alex Rivera | Logout

Is it possible that when click edittext it will show dialog message?

Asked 2011-06-10T04:43:32.933
15

I want to click a edittext and show dialog date so I try

mDateDisplay = (EditText) findViewById(R.id.dateDisplay);
    mDateDisplay.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                showDialog(DATE_DIALOG_ID);
            }
        }
    });

The dialog will show if mDateDisplay is a button

but I want to use edittext

what should I do?

Edit
Report

1 Answer

49

You can use OnClickListener event to handle the dialog box but after disabling the android:focusableInTouchMode of EditText in the xml file like this. eg - android:focusableInTouchMode="false".

Because when the EditText is first touched it calls the focus event and on second touch it call the click event so you have to disable the focus event first.

answered 2011-06-10T05:03:18.390

Your Answer