Hello all, I have a simple layout with a Gallery and a ListView. What I want to do is move through the gallery using the trackball and update the ListView as I select items in the Gallery. However, there is a problem where the gallery loses focus as soon as it selects an item. I don't think this is the right behavior, so I started digging into the details and here is what I found.
I start out with the Gallery focused. When I move the trackball to the right, the Gallery properly focuses the next selected view and calls the onItemSelected callback. My OnItemSelectedListener's onItemSelected calls the ListView adapter's "notifyDataChanged" method to update the ListView. The "notifyDataChanged" method calls onChanged of the data observer. The data observer is the AdapterView's AdapterDataSetObserver, and that method calls requestLayout. The requestLayout triggers a traversal of the entire view tree and then the Gallery's layout method unfocuses the selected item. It then throws the focus off completely. What I had to do to work around this was create a sub-class of ListView and override the requestLayout method to do nothing. Then I had to make layoutChildren public. Finally, I just called layoutChildren after each notifyDataChanged call I made to the adapter. Is there an alternate way to update my ListView in response to selecting an item in the gallery? Or do we have a problem here? My last note is I think Gallery has a bug here. It seems if you call layout a second time, it will lose focus? Please let me know if you need a concrete code example. Thank you, -Brian --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

