必须单击两次才能调用edittext android的onclick方法

beg*_*ass 5 events android click launch android-edittext

我的android活动中有这个editText

         <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" />
Run Code Online (Sandbox Code Playgroud)

正如您在用户点击时所看到的那样

我调用这个方法来启动datePickerDialog:

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

}
Run Code Online (Sandbox Code Playgroud)

我遇到的问题是:在我第一次打开此活动时,用户必须单击两次才能启动对话框

但在那之后,只需点击一下即可

我该如何解决这个问题

hyp*_*d09 16

检查类似问题

"第一次点击只是将焦点设置为TextBox,然后第二次点击实际上被处理为点击."

尝试设置 android:focusable="false"