I am working on a storage handling application(real storage). My app. is calling on button push the ZXing barcode reader, after scaning the code, a new activity(window) pops up. Where i can read the scanned code, and i can put in an amount(how much i want from that product). I got there a next and a finish button, on the finish button i go back to the main window. On the next button, the ZXing is called again, i scan the result window pops up , amount input and so on so on… Now to the question, i am going to store the scannedcode+amount in an array. So i can display them in a ListView. I got this:
String[] names = new String[] { "Linux", "Windows7", "Eclipse", "Suse", "Ubuntu", "Solaris", "Android", "iPhone"};
so i know thats how i make an array with data and thats how i display it:
this.setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_checked, product));
I would like to know how i do an empty array, and how i can add new string to it when ever i push the Next button, i will pass the array with bundle between the activitys. So thats it. Uhm and yea is it possible to edit a specific part of the array, cause thats the reason of the list where i show the array to the user, so he can go for example on the Eclipse row, click it and he can write in Android and save.
I hope some one can help or give me some hint on both problems. Thank you in front.
You’d be more flexible if instead you used an ArrayList. You don’t need to change the ArrayAdapter part because it has a constructor that works with ArrayLists.
See the doc here: http://developer.android.com/reference/java/util/ArrayList.html
ArrayList allows you to replace, append, and remove as many elements as you want without worrying about reallocating your array or any other low level operation you’d need to do if you’d implemented your own data structure.
Here’s an entire example that I was playing with the other day: