ActionBarSherlock
                                
                                
                                
                                    ActionBarSherlock copied to clipboard
                            
                            
                            
                        ActionMode creates duplicate/overlapping icons if a menu inflater is used
In an ActionMode.Callback implementation, we did the following:
public boolean onCreateActionMode(ActionMode mode, Menu menu) { getSupportMenuInflater().inflate(R.menu.action_mode_menu, menu); return true; }
The action mode comes and goes fine the first time. However the second time you can feel the animation is a bit gerky and the buttons are in fact 'overlapping' another set of similar buttons. To prove this, rotate the phone (and if you have onConfigChanges='orientation' it won't recreate your whole view) and you'll see 'two' sets of buttons appear in landscape. The first set is pushed to the left but the second set.
The problem goes away completely if you construct the menu manually by code.
To add on to this, this happens specifically if you call invalidateOptionsMenu(). We've removed all such calls and ensure we don't update or invalidate the ActionMode during or around the time it's hiding.
Do you mean you were calling invalidateOptionsMenu yourself or you removed it from the ABS implementation?
I'd love a proper demo .zip of this. I don't really have time to figure out what exactly you were doing and the release is only a few days away. It would help everyone.
Jake I'd love to give you a demo app but I really don't know where to begin now (since our own app is immensely complex). I've actually forgotten what I was doing however I went back and looked at the code. All I can see is the code that I wrote to 'fix' the problem. I moved all the code from 'onActionItemClicked' within the ActionMode.Callback to the onDestroyActionMode (so basically if the user clicks something, I first close the ActionMode and then open the activity in onDestroyActionMode based on user's selection). This somehow ensured that the ActionMode and it's current animation had ended completely before launching a new Activity.
It seems within the current activity I was possibly invalidating or calling 'finish()' again on the actionmode callback in 'onPause' and that might have been killing the actionmode mid-way. Then the next time the actionmode was created, somehow the 'old' stale bar was still showing underneath or on the left if the phone was rotated.
Either way if I do whatever I want to do in onDestroyActionMode (i.e. open a new activity) I ensure the ActionMode has finished animating completely and is now destroyed. This way I was able to fix the problem completely.
I should point out this problem (i.e. before my fix to move the code to onDestroyActionMode from onActionItemClicked) does not exist on Icecream Sandwich. It used to work fine there but was failing on all other devices (OS 2.x).
I do still suspect I was doing something funny (perhaps calling .invalidate() or finish() a second time while the actionmode) while I had already called 'mode.finish()' in onActionItemClicked inside the callback.
I'm sorry for being vague but I did try to reproduce the issue again just now but wasn't able to (possibly because I've forgotten what was causing it and I made far too many changes to ensure it's fixed).
That's alright. I'm pretty sure this is related to #331 so hopefully once it's fixed this will be too.