I have an ExpandableListView
and then some other control that can have focus to the right of it. Something like this. Note: Child2 is selected开发者_如何学JAVA.
Group1
Child1 +-----------------------+
*Child2* | |
Child3 | Other focusable View. |
Child4 | |
Child5 +-----------------------+
Using the d-pad, if I press right, focus goes to the other view. At that point if I press left on the d-pad, focus returns to my ExpandableListView
, but Child3 gets selected instead of Child2 (because it's in the center).
In general, how can I ensure that the previously selected child remains the selected child when focus leaves and then returns to my ExpandableListView
? Any ideas on a work around? I tried caching the current selection then calling setChildSelected()
, but for some reason the selection doesn't happen.
Well, I solved it by caching the current group and child when focus is lost and then explicitly re-setting the group / child when the listview re-gains focus. I had to also disable the listview and re-enable it in various places. It's a hack, but it works.
精彩评论