Search code examples
androideventsclickandroid-edittextlaunch

have to click two times to call an onclick method of edittext android


I have this editText in my android activity

         <EditText
            android:id="@+id/payment_expiration"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/payment_expiration_label"
            android:layout_centerHorizontal="true"
            android:layout_marginLeft="25dp"
            android:layout_marginRight="25dp"
            android:clickable="true"
            android:onClick="update_expiration_date"
            android:editable="false"
            android:layout_marginTop="-4dp"
            android:cursorVisible="false"
            android:maxLength="7"
            android:padding="10dp"
            android:textSize="13dp" />

as you can see when the user click on

I call this method which launch a datePickerDialog :

    public void update_expiration_date(View v){
    Log.i("","cliqué");
    picker.show();
    can_update_expiration_date = true;

}

the problem I encouter is : in the first time just when I open this activity, the user must click two times to launch the dialog

but after that, one click is sufficient

how can I fix this issue


Solution

  • Check Similar Question

    "The first click just sets the focus to the TextBox then the second click actually gets handled as a click. "

    try setting android:focusable="false"