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
I have a list of positions of array to retrieve ,This worked for me.
public void create_list_to_add_group(ArrayList arrayList_loc) {
//In my case arraylist_loc is the list of positions to retrive from
// contact_names
//arraylist and phone_number arraylist
ArrayList group_members_list = new ArrayList<>();
ArrayList group_members_phone_list = new ArrayList<>();
int size = arrayList_loc.size();
for (int i = 0; i < size; i++) {
try {
int loc = arrayList_loc.get(i);
group_members_list.add(contact_names_list.get(loc));
group_members_phone_list.add(phone_num_list.get(loc));
} catch (Exception e) {
e.printStackTrace();
}
}
Log.e("Group memnbers list", " " + group_members_list);
Log.e("Group memnbers num list", " " + group_members_phone_list);
}