Tip:
Highlight text to annotate it
X
We declare the ArrayList and ArrayAdapter to store String values
now we run the constructor on the ArrayList
the constructor for the ArrayAdapter requires three values: a context, a textviewresourceID and the items to display (in this case our ArrayList)
finally we tell our ListView to use the ArrayAdapter as its data source
we will create a function to add a text string to our ArrayList
we pass in the text String in as a parameter
we ignore the text String if it is empty
we push the text String onto the end of the ArrayList
tell the ArrayAdapter the data has changed...
...and delete the contents of the EditText box ready for the next item
we check to see if the Button btnAdd has been clicked
and call the addItem function passing the contents of the EditText box
we check to see if the key was pressed down and whether that key was the centre button on the D-PAD
and call the same function with the same value
and we test our finished application...