I have in my application a part where the user must select a contact from the list of contacts, I could and I managed to bring the list with the phone, like the following image:
This here is a spinner, with a CURSOR as a data source, my question is this: how could I add a search engine in this spinner?
my code so far is
Spinner imgpayment = (Spinner)findViewById(R.id.imgpayment);
Cursor mCursor = getContentResolver().query(
ContactsContract.Data.CONTENT_URI,
new String[] { ContactsContract.Data._ID, ContactsContract.Data.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER,
ContactsContract.CommonDataKinds.Phone.TYPE },
ContactsContract.Data.MIMETYPE + "='" + ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE + "' AND "
+ ContactsContract.CommonDataKinds.Phone.NUMBER + " IS NOT NULL", null,
ContactsContract.Data.DISPLAY_NAME + " ASC");
startManagingCursor(mCursor);
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
android.R.layout.simple_list_item_2,
mCursor, // cursor
new String[] { ContactsContract.Data.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER }, // cursor
new int[] { android.R.id.text1, android.R.id.text2 }
);
imgpayment.setAdapter(adapter);
I already tried to use the SpinnerDialog that I found investigating and it appears to me like that
until here everything is perfect, but I can not make it show the name and number, I can only choose one of the 2 and it is unviable, the code of the second image is
ArrayList<String> contactos = new ArrayList<String>();
mCursor.moveToFirst();
while(!mCursor.isAfterLast()) {
contactos.add(mCursor.getString(mCursor.getColumnIndex("DISPLAY_NAME"))); //add the item
mCursor.moveToNext();
}
spinner = new SpinnerDialog(this,contactos,"Elegir Contacto",3);
spinner.bindOnSpinerListener(new OnSpinerItemClick() {
@Override
public void onClick(String s, int i) {
String a = s ;
String b = s ;
}
});
btnShow = (Button)findViewById(R.id.Bottton);
btnShow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
spinner.showSpinerDialog();
}
});
how could the first add a filtering?