Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 477
user790156 Avatar asked Jun 10 '11 04:06

user790156


1 Answers

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.

like image 179
Lalit Poptani Avatar answered Oct 10 '22 21:10

Lalit Poptani