1

I'm trying to store a value to an array on a button click and then recall it once store in an array.

This is my array code:

public class Favorites extends ListActivity {
    static ArrayList<String> ItemArray = new ArrayList<String>();


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Full Screen
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.favorites);


    }


    public void add(String Item) {
        ItemArray.add(Item);


    }


}

This is the is the code I have in the button click

String Item;
Item=getItem();

Bundle value= new Bundle();
value.putStringArrayList(Item, MyArrayClass.ItemArray);
1
  • Sorry, It wasn't adding the value to the array. Commented Jun 23, 2011 at 17:40

1 Answer 1

2

Not quite sure what your asking here but if you want to add something to the array list you would call:

ItemArray.add(Item); 

Like you have in your add function, to get a value from the array list, call:

ItemArray.get(i);

where i is the index of the item you want. Hope this helps!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.