I have dialog with 2 horizontal galleries and one LinearLayout, and i have problem with focus.
It looks like this:
Gallery 1
Gallery 2
LinearLayout
Gallery 2 is some kind of submenu of Gallery 1.
I’ve implemented onItemSelected listener for both galleries. When i select something in Gallery1 content of Gallery 2 is changed and focus stays on Gallery 1. And it work fine.
When i select something in Gallery 2 i have to inflate xml file in LinearLayout and do something with that.
Problem is when i select something in Gallery 2, and inflate xml in LinearLayout…focus goes on Gallery 1, but I need it to stay on Gallery 2, until I press Up or Down or whatever. Don’t know what is the problem, it makes no sense to me.
Do you have some idea?
Gallery2.requstFocus() doesn’t help.
I’ve forgot about this problem, ‘couse i’ve gave up 🙂
But recently i had a similar problem and solve it…
The fact is that requestFocus command doesnt have time to done its work if your GUI is complex.
Its a Android bug…
I’ve solve similar problem with some kind of finite state machine and threads to update focus.
I have one variable which represent states, for focus…which item has to focused.
I have made one thread for each state.
In thread I do something like this:
item1.clearFocus();
item2.clearFocus();
item3.requestFocus();
Hope you understand what I want to say.
In my app when i need to focus particular item, i just start the “updating focus thread” for that item.
Thats all, hope u solve yours problem.