It is necessary that when the on-screen keyboard appears (when you click on EditText ), one code is executed, and when it is hidden, another one. When creating an activity keyboard is hidden.

The variant with OnFocusChangeListener does not roll, because EditText is the only field on the activity and it is always in focus.

    3 answers 3

    In general, to catch the actual appearance or disappearance of IME is unrealistic. You can be attached to the resizing of the window, but again this can work differently for different IMEs. Therefore, it remains only to catch clicks and clicks.

    • Thank. Both answers helped and did so. Just hoped that there is a more elegant solution. - Tuhlom

    There is a fairly simple and more / less elegant solution that works for me. Perhaps somehow help future "adventure seekers" =)

      Hello. Try setOnTouchListener .