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
public class DemoActivity extends Activity {
/** Called when the activity is first created. */
ArrayList al = new ArrayList();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// add elements to the array list
al.add("C");
al.add("A");
al.add("E");
al.add("B");
al.add("D");
al.add("F");
// retrieve elements from array
String data = al.get(pass the index here);
System.out.println("Data is "+ data);
This is another way of getting element
Iterator it = al.iterator();
while (it.hasNext()) {
System.out.println("Data is "+ it.next());
}
}