OnClick event only works second time on edittext

Solution 1:

Simply try to add this to your XML file. Your keyboard pops up when widget gains focus. So to prevent this behaviour set focusable to false. Then normal use OnClickListener.

<EditText
  android:focusable="false"
  ...
/>

Now, it should works.

Solution 2:

You can use onTouch instead of onClick, so it doesn't matter if the EditText has focus or not.

edt.setOnTouchListener(new OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) { 
        CommentDialog.buildDialog(mContext, identifier, false, edt.getId());                    
        return false;
    }
});

Solution 3:

Nothing much to do you just have to

edt.setFocusable(false);

Solution 4:

If focusableInTouchMode is true then touch is triggered in second touch only, so unless you want that case use false for focusableInTouchMode. and if you want to enable the focusability in the view set focusable true

<EditText android:focusable="true"  android:focusableInTouchMode="false" ... />