Has anyone seen this behavior in ICS? 

What's happening is if a fragment is participating in the options menu for 
an activity both the activity's and fragments onCreateOptionsMenu is being 
called twice when the phone is rotated but only once when the activity is 
initially started. (See my linked stackoverflow.com question below for 
complete code and output)

The bigger problem is that if a fragment adds a SearchView to the options 
menu, the SearchView can't remember it's state when the phone is rotated. 
It's no longer has any text in the textview after the rotation. If the 
activity uses a searchview, the state is saved correctly when rotated.

I've seen this on the emulator running ICS 4.0 (API 14) and 4.0.3 (API 15) 
and also Verizon Galaxy Nexus running 4.0.4 build IMM76K. 

I can't figure out what's causing the onCreateOptionsMenu to be called 
twice. It doesn't make sense that this would be the normal way to create 
the options menu when rotating the phone. Maybe I'm doing something wrong 
to cause this? or I need to handle the onCreateOptionsMenu differently when 
the phone state is changed.

Here's my question on stack overflow. This is complete with example code 
and log output of what I'm seeing.
http://stackoverflow.com/questions/11003941/android-oncreateoptionsmenu-called-twice-when-restoring-state#comment14380762_11003941

Thanks ahead of time for any help.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to