1

Note: I am not sure to post this question or should I reopen the previous question. I am posting this because It is only related to (4.2 version)

It seems this question repeating again previously it was posted here, but this time this issue only persist on Nexus7 (4.2 version)

Otherwise it is working fine on all other version up to 4.1.2 (tested even on Nexus 4.1.2).

I have tried/checked with all the suggestions and possibility posted here

Could any one explain this issue and also please provide a fix for this. Thank you

Community
  • 1
  • 1
vinay kumar
  • 1,451
  • 13
  • 33

1 Answers1

0

You should probably show some code because I have no idea if what I'm about to post will help you out or not.

My Issue (Similar to Question) What I noticed in 4.2 (SG4) but not earlier versions was EditText gaining focus after onResume() during activity creation. This issue did not always occur but seemed more prevalent when the keyboard was open and closed in the activity.

My scenario - Two EditText boxes, let's call them A and B, where A in xml had requestFocus>/requestFocus>. Both had onFocusListners. After onCreate, A would have focus. After onResume during creation, B would have focus. No idea why. Both onFocusListners would change the screen layout and I wanted to avoid focus changes to B prematurely.

My work around - I inserted a third EditText in between A and B in xml. Let's call it Z. Z had to have visibility set to VISIBLE. Z had to also have a dummy onFocusListner that did nothing. Running this caused Z to gain focus. To return focus back to A and remove Z from the layout I had to do the following: in onCreate I did a postDelayed() on view Z where in the run method i changed focus to A and set the visibility of Z to gone. Delayed 100ms. I tried onPostResume() instead of postDelayed() but that did not work.

LEO
  • 2,572
  • 1
  • 26
  • 31