mainList.get(list_index)
Time to familiarize yourself with the ArrayList
API and more:
ArrayList
at Java 6 API Documentation
For your immediate question:
mainList.get(3);
Try:
ArrayListname.get(index);
Where index
is the position in the index and ArrayListname
is the name of the Arraylist as in your case is mainList.
We print the value using mainList.get(index) where index starts with '0'. For Example: mainList.get(2) prints the 3rd element in the list.
I have been using the ArrayListAdapter to dynamically put in the entries into the respective fields ; This can be useful , for future queries
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
And then , you can fetch any arraylist item as below :
arrayListName(info.position);
You can simply get your answer from ArrayList API doc.
Please always refer API documentation .. it helps
Your call will looklike following :
mainList.get(3);
Here is simple tutorial for understanding ArrayList with Basics :) :
http://www.javadeveloper.co.in/java/java-arraylist-tutorial.html
mainList.get(3);
For future reference, you should refer to the Java API for these types of questions:
http://download.oracle.com/javase/1.4.2/docs/api/java/util/ArrayList.html
It's a useful thing!
Source: Stackoverflow.com