1. Download our Official Android App: Forums for Android!

Apps Saving values from a (Float) ArrayList into a Bundle

Discussion in 'Android Development' started by droidzip, Dec 4, 2012.

  1. droidzip

    droidzip Lurker
    Thread Starter
    Rank:
    None
    Points:
    6
    Posts:
    5
    Joined:
    Oct 26, 2012

    Oct 26, 2012
    5
    1
    6
    I'm writing a game using Surfaceview and have a question relating to saving Data into a Bundle.

    Initially, I had an arraylist which stored the Y co-ordinates (in the form of Integers) of sprites that will move only up and down. Declared as:

    I saved them to a Bundle using the following:

    And restored them using this:

    This all worked perfectly. However, I've had to change the whole coordinates system so it's based on Delta time to allow my sprites to move at a uniform speed across different screens. This is, again, working perfectly.

    However, as a result of this change, I now have to store these values as floats rather than integers.

    So, I am declaring as:

    So that's the background, now my question is, how do I store and restore values from a Float Arraylist? There doesn't seem to be a "putFloatArrayList" or "getFloatArrayList".

    (I've used an Arraylist rather than an Array as the number of sprites needs to be dynamic).

    Any help would be appreciated.

    Many thanks
     

    Advertisement

  2. myrecek

    myrecek Newbie
    Rank:
    None
    Points:
    16
    Posts:
    29
    Joined:
    May 10, 2012

    May 10, 2012
    29
    2
    16
    You can either convert the list to an array, put it in the bundle using putFloatArray and than after getting it convert it back to a list. Or you can use putSerializable and getSerializable.
     

Share This Page

Loading...