0

This is from contactHandlerDatabase class

public List<Contact> displayAllContact(){

    //display all the contact in repertoire
    List<Contact> AllContactList= new ArrayList<Contact>();//create the arraylist of contact

    SQLiteDatabase db=this.getWritableDatabase();//in writable mode

    Cursor cursor=db.rawQuery(SELECT_ALL_QUERY+TABLE_NAME,null);


    if(cursor.moveToFirst()){

        do{//capture data of all columns in each row

            Contact contact=new Contact();

            contact.setContactName(cursor.getString(0));

            contact.setContactSurname(cursor.getString(1));

            contact.setContactTel(Integer.parseInt(cursor.getString(2)));

            contact.setContactEmail(cursor.getString(3));

            AllContactList.add(contact);//add all column data to list

        }while (cursor.moveToNext());

    }//end if

    return AllContactList;

}

This is from CallHistory class

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    super.onActivityResult(requestCode, resultCode, data);


    List<Contact> AllContactList;

    switch (requestCode){

        case REQ_CODE_SPEECH_INPUT:{

            if ((resultCode == RESULT_OK) && (data != null)) {


                ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);

               AllContactList=db.displayAllContact();

**enter code here**

                ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,R.layout.activity_repertoire,R.id.lblCallHistory,AllContactList);


            }//end if

            else{
                convertToSpeech("Discours incoherent");
            }//end else

        }//end case

        break;

    }//end switch

}//end of onActivityResult method

I don't know how to implement the AllContactList inside the ArrayAdapter because it is requesting for List as parameters. Please HELP

Ikhlak S.
  • 8,578
  • 10
  • 57
  • 77
Liza
  • 1
  • 2
    why are you trying to convert it to `ArrayAdapter` Instead of converting this to `ArrayAdapter` ? – Shree Krishna Mar 13 '16 at 09:23
  • Create custom adapter and set it to `ListView` or `Spinner`...[here](http://stackoverflow.com/questions/8166497/custom-adapter-for-list-view) is how – ELITE Mar 13 '16 at 09:43
  • as @ShreeKrishna said, change it to ArrayAdapter, and if you have access to `Contact` class override `toString()` make it return whatever you want to appear in the list item, or use a full-custom adapter, and in `getView()` get whatever member of Contact you want and display it in the list item – Yazan Mar 13 '16 at 10:42

0 Answers0