Simon A. Callaghan Jensen Simon A. Callaghan Jensen - 1 year ago 131
Android Question

TimePicker Dialog when pressing EditText

This question has been asked before, but the answers from back then, doesn't seem to work in Android Studio anymore, or else i'm missing something.

I want a timePicker dialog to show up when you press the edit text area, to set the time in the editText. However, for some reason, the normal keyboard simply pops up when pressed. I'm not getting any errors, though it still doesn't seem to work.

here is the code:

final EditText Edit_Time = (EditText) findViewById(;

Edit_Time.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub
Calendar mcurrentTime = Calendar.getInstance();
int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY);
int minute = mcurrentTime.get(Calendar.MINUTE);

TimePickerDialog mTimePicker;
mTimePicker = new TimePickerDialog(TimeActivity.this, new TimePickerDialog.OnTimeSetListener() {
public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
Edit_Time.setText( selectedHour + ":" + selectedMinute);
}, hour, minute, true);
mTimePicker.setTitle("Select Time");;


the xml part of editText:


If anyone can help, then it's much appreciated, Thanks!

Answer Source

Add these properties to your EditText tag in xml to disable keyboard popping up



Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download