I found that when using the d-pad or trackball to navigate in my application, if you move to the right, and in list mode it stops focusing, when viewing the list regains focus, the other child is given more attention than in the past, focus, I tried to use onFocusChange (...) to preserve what kind of focus the child had, but it does not seem to be called until the focus is lost, so I can never capture the one who had the last focus. Is there a way to capture those who had the focus, so I can then call requestFocus () on the child when the list view will capture the focus again?
Unfortunately, I cannot use a handler because it is not a very used function, and I do not want to sacrifice performance for a smaller function.
Here is the code I had that didn't work (focusView was always null, no matter what):
mainListView.setOnFocusChangeListener(new OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { if(focusedView == null ) { Log.i("focus", "focusedView == null"); } if(hasFocus && focusedView != null) { Log.i("focus", "Focus has been Recieved............."); focusedView.requestFocus(); } else {
Thanks!
source share