Retrieving an element from array list in Android?

后端 未结 6 2054
醉话见心
醉话见心 2021-02-01 07:16

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

6条回答
  •  悲哀的现实
    2021-02-01 07:54

    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);
    
    }
    

提交回复
热议问题