If I had to guess, your problem is that you are creating extra
fragments. For example, at least on a complete rotation (portrait ->
landscape -> portrait), you will have two of everything. Remember that
your fragments will automatically be re-created on a configuration
change, so you do not want to create separate copies. Get your old
ones from the FragmentManager, and only create them if the
FragmentManager does not already have them.


On Sat, Feb 9, 2013 at 3:29 PM, FiltrSoft <kri...@gmail.com> wrote:
> On Saturday, February 9, 2013 2:39:17 PM UTC-5, Mark Murphy (a Commons Guy)
> wrote:
>>
>> You claim that your problem is in onCreateOptionsMenu(), yet you do
>> not appear to implement it.
>>
>
> Whoops, not sure what happened there, didn't paste Fragment:
>
>
> MyListFragment.class
>
> public class MyListFragment extends SherlockListFragment
> {
>     @Override
>     public void onCreate(Bundle savedInstanceState){
>         super.onCreate(savedInstanceState);
>
>         setHasOptionsMenu(true);
>     }
>
>     public static MyListFragment newInstance() {
>
>         return new MyListFragment();
>     }
>
>     @Override
>     public View onCreateView(LayoutInflater inflater, ViewGroup container,
> Bundle savedInstanceState) {
>         super.onCreateView(inflater, container, savedInstanceState);
>
>         return inflater.inflate(R.layout.listing, container, false);
>     }
>
>     @Override
>     public void onActivityCreated(Bundle savedState) {
>         super.onActivityCreated(savedState);
>
>         DisplayItems();
>     }
>
>     @Override
>     public void onPrepareOptionsMenu(Menu menu) {
>         super.onPrepareOptionsMenu(menu);
>     }
>
>     @Override
>     public void onCreateOptionsMenu(final Menu menu, final MenuInflater
> inflater) {
>         inflater.inflate(R.menu.listing_menu, menu);
>
>         super.onCreateOptionsMenu(menu, inflater);
>     }
> }
>
> MyDetailFragment.class
>
> public class MyDetailFragment extends SherlockListFragment
> {
>     public int mId;
>
>     @Override
>     public void onCreate(Bundle savedInstanceState)
>     {
>         super.onCreate(savedInstanceState);
>         setHasOptionsMenu(true);
>     }
>
>     public static MyDetailFragment newInstance(int id) {
>
>         MyDetailFragment lf = new MyDetailFragment();
>         Bundle bundle = new Bundle();
>         bundle.putInt("id", id);
>         lf.setArguments(bundle);
>
>         return lf;
>     }
>
>     @Override
>     public View onCreateView(LayoutInflater inflater, ViewGroup container,
> Bundle savedInstanceState) {
>
>         if (getArguments() != null)
>             mId = getArguments().getInt("id");
>
>         return inflater.inflate(R.layout.details, container, false);
>     }
>
>     @Override
>     public void onActivityCreated(final Bundle icicle)
>     {
>         super.onActivityCreated(icicle);
>
>         DisplayItems();
>     }
>
>     @Override
>     public void onPrepareOptionsMenu(Menu menu) {
>
>         super.onPrepareOptionsMenu (menu);
>     }
>
>     @Override
>     public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
>         inflater.inflate(R.menu.details_menu, menu);
>
>         super.onCreateOptionsMenu(menu, inflater);
>     }
> }
>
>
> --
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to android-developers+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 4.5 Available!

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to