I have code to display contacts but i have find difficult to display contacts after @ symbol ..Kindly Help...
public class AutoCompleteTextViewActivity extends Activity {
String[] result;
String[] datacols = new String[]{
ContactsContract.CommonDataKinds.Phone._ID,
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.NUMBER,};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
loadingContacts();
}
public void loadingContacts() {
ContentResolver cr = getContentResolver();
Cursor cursor = cr.query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI, datacols,
null, null, null);
startManagingCursor(cursor);
int count = cursor.getCount();
result = new String[count];
int contact_name = cursor
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME);
int contact_number = cursor
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
int i;
long temp;
for (cursor.moveToFirst(), i = 0; !cursor.isAfterLast() && i < count; cursor
.moveToNext(), i++) {
temp = cursor.getLong(contact_number);
result[i] = cursor.getString(contact_name) + "\n" + temp;
}
ArrayAdapter<string> adapter = new ArrayAdapter<string>(this,
android.R.layout.simple_dropdown_item_1line, result);
AutoCompleteTextView textView = (AutoCompleteTextView)
findViewById(R.id.txtCountries);
textView.setThreshold(0);
textView.setAdapter(adapter);
}
}