开发者

Android: Adding/Calling values from array

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


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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜