In my application I'am just calling DatePicker
when i click the EditText
.
But when I test this, first it ask us to edit and if I again click that then it will show the DatePicker
.
I want to show only DatePicker without editable.
In my application I'am just calling DatePicker
when i click the EditText
.
But when I test this, first it ask us to edit and if I again click that then it will show the DatePicker
.
I want to show only DatePicker without editable.
put this 2 lines in your edittext xml code
android:focusable="false"
android:focusableInTouchMode="false"
private DatePickerDialog.OnDateSetListener pickerListener =
new DatePickerDialog.OnDateSetListener() {
// when dialog box is closed, below method will be called.
@Override
public void onDateSet(DatePicker view, int selectedYear,
int selectedMonth, int selectedDay) {
year = selectedYear;
month = selectedMonth;
day = selectedDay;
ArrivalDate = new Date(year - 1900, month, day);
textArrivalDate.setText(new StringBuilder().append(month + 1)
.append("/").append(day).append("/").append(year)
.append(""));
}
};
Use the following code block with on TextView Click event:
Calendar c = Calendar.getInstance();
datePickerDialog = new DatePickerDialog(this, pickerListener,
c.get(Calendar.YEAR), c.get(Calendar.MONTH),
c.get(Calendar.DAY_OF_MONTH));
datePickerDialog.SetTitle("Select date");
datePickerDialog.show();
try this. by adding these lines to edittext
android:inputType="none"
android:clickable="true"
android:focusable="false"
and in onclick do wat u want.
Don't use an EditText
then.
An EditText
is meant to let the user input text using a keyboard...
Use a clickable TextView
, or a kind of Button
instead.
simplest way to do this use setOnFocusChangeListener instead of OnCLickListner following code is an example which i am using for same purpose.
editText_dob.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if(hasFocus){
hideSoftKeyboard(RegisterationActivity.this);
editText_dob.setRawInputType(InputType.TYPE_CLASS_TEXT);
setDate(editText_dob);
}
}
});