MikeS
MikeS

Reputation: 3921

Android: Detect When Soft Keyboard Is About to Show?

Is there a way to detect when the keyboard is about to be presented in Android?

My problem is that I have a ListView with EditTexts in it. When the keyboard is about to be presented, these are quite often redrawn, causing an EditText that was JUST tapped to lose focus and require an extra tap.

My proposed solution is to monitor when the keyboard is about to be shown, check to see which view currently has focus, then after the keyboard is done being shown, restore focus to that view.

However, I have no idea how to detect when the keyboard is "about to be shown" in Android. How would I do this?

(I would also accept an alternative answer that addresses my actual problem: EditText losing focus when keyboard is displayed)

Upvotes: 0

Views: 926

Answers (1)

MariusBudin
MariusBudin

Reputation: 1287

You could do it the other way, create an unique OnFocusChangedListener myListener and set it to all your EditTexts and put a switch inside and store which is the last view getting/losing focus

Upvotes: 1

Related Questions