0

This has been bugging me for a few days now. I have a FrameLayout and one of the elements within the layout moves to reveal a menu. I can paste the code if requested, it's a bit long since it's my play code and I haven't used any styles. I digress...

When the user presses a particular button it calls a startAnimation on a custom LinearLayout which is layered on top of another stock LinearLayout. Pushing the button again will put the custom LinearLayout back to it's original location, thus hiding the menu.

I had to create a custom LinearLayout to override onAnimationEnd so the layout would stop and stay at the final animated position (I found this based on some other questions asked here on StackOverflow).

The problem arises when the user actually presses one of the visible menu items. One of the items, for example, sorts or reverse sorts the displayed list. It appears that right after I call notifyDataSetChanged on my BasicAdapter the screen redraws itself and my menu is hidden. I have no code that closes the menu, it's almost like the entire Activity is re-created or reset when the list is told to redraw.

I should also point out that I'm extending an Activity not a ListActivity. I'm targeting API 10 (Gingerbread, 2.3) and up.

If any one has any pointers, I would greatly appreciate it. I've been wracking my brain on this for days now and it's driving me crazy. Please let me know if I can provide any more info.

EDIT: Here's the SO post about overriding the onAnimationEnd method. Android TranslateAnimation resets after animation

Community
  • 1
  • 1
themanatuf
  • 2,880
  • 2
  • 25
  • 39

1 Answers1

0

Do you record which item's menu has been opened yourself? If not, then it means that you let the UI system do the remembering for you, which would mean that this information would be lost or rendered useless (since you have changed the item ordering), so all the items reverts to their initial states. The solution is to associate the menu opened/closed state with each data in the list, then when the adapter's getView method is called, you can rebuild the correct UI state.

Kai
  • 15,284
  • 6
  • 51
  • 82
  • Thanks for the help. I was keeping track of when the menu was opened or not, but I have a feeling you were right in that the UI was remembering stuff as well, albeit the "wrong" stuff. I ended up using a ScrollView instead and programmatically change the scroll position. Thanks again, you forced me to step back and rethink my approach. – themanatuf Jan 02 '13 at 03:24