I am trying to implement voice recognition code in Android. How do I get an element at a particular position from array list in Android? I tried converting arraylist
What I understand your question is that you want to fetch an element in an ArrayList
at a specific location.
Suppose your list contains Integers 1,2,3,4,5 and you want to fetch the value 3. Then the following lines of code will work.
ArrayList list = new ArrayList();
if(list.contains(3)){//check if the list contains the element
list.get(list.indexOf(3));//get the element by passing the index of the element
}
Either ways you could use list.get(list.lastIndexOf(3))