I can't see anything wrong with the code. Do you get the same problem
in TitlesFragment.java when running the honneycomb-gallery sample
included in the SDK?

On 28 Juli, 11:54, "Maria D." <dobr...@gmail.com> wrote:
> I'm new to android and I'm facing the following problem. I'm
> developing for both, Android 2 and 3, and this is why I use fragments.
> However to make the app working on Android 2 devices I import
> android.support.v4.app.ListFragment (not sure if it makes any
> difference with this problem). I need to maintain selection within my
> ListFragment when orientation of the screen changes. I'm overriding
> onSaveInstanceState() method and put an int into the bundle. When the
> screen is rotated, this method is called and the int is added to the
> bundle. However when onActivityCreated() is called, its bundle is
> null. I am following the example provided on Android 
> website:http://developer.android.com/reference/android/app/Fragment.html, but
> as mentioned above - after onSaveInstanceState() is called, the bundle
> in onActivityCreated() is still null.
>
> Here's the code:
>
> import android.support.v4.app.ListFragment;
> public class VisitsHomeFragment extends ListFragment {
>     private int selectedPosition = -1;
>
>     @Override
>     public void onActivityCreated(Bundle savedInstanceState) {
>         super.onActivityCreated(savedInstanceState);
>         if (savedInstanceState != null) {  //savedInstanceState is
> always null here!
>             if (savedInstanceState.containsKey("SELECTED_POSITION")) {
>                 selectedPosition =
> savedInstanceState.getInt("SELECTED_POSITION");
>             }
>         }
>     }
>
>     @Override
>     public void onSaveInstanceState(Bundle outState) {
>         super.onSaveInstanceState(outState);
>         outState.putInt("SELECTED_POSITION", selectedPosition);
>     }
>
> }
>
> I would appreciate any help with this problem.

-- 
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