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?
Use this:
Alternatively, you can use the
android:onClickattribute in the XML to point to a click-handling function in your Activity subclass.(These days, of course, when pretty much everyone uses the compatibility libraries, you would probably want to create and show a dialog fragment rather than calling
showDialog(), but the idea is the same.)