I have this piece of code that 2 EditText are using. The first one is work well but the second one is causing the application to crash with the error below. Any advise? I have taken a look at this question but it doesn't have a working solution.
public class EditTextDatePicker extends AppCompatEditText {
public EditTextDatePicker(Context context) {
super(context);
this.initialize();
}
public EditTextDatePicker(Context context, AttributeSet attributeSet){
super(context, attributeSet);
this.initialize();
}
public EditTextDatePicker(Context context, AttributeSet attributeSet, int defStyle){
super(context, attributeSet, defStyle);
this.initialize();
}
private void initialize(){
this.setTextIsSelectable(true);
this.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if(hasFocus){
DatePicker dialog = new DatePicker(v);
dialog.show(TaskCreateUpdateDelete.fragmentTransaction, "DatePicker");
}
}
});
}
}
Here is the error:
05-22 23:26:31.479 1703-1703/comp3350.taskmanager E/InputEventReceiver: Exception dispatching input event.
05-22 23:26:31.480 1703-1703/comp3350.taskmanager E/MessageQueue-JNI: Exception in MessageQueue callback: handleReceiveCallback
05-22 23:26:31.481 1703-1703/comp3350.taskmanager E/MessageQueue-JNI: java.lang.IllegalStateException: commit already called
at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:625)
at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:617)
at android.support.v4.app.DialogFragment.show(DialogFragment.java:156)
at views.EditTextDatePicker$1.onFocusChange(EditTextDatePicker.java:36)
at android.view.View.onFocusChanged(View.java:5206)