在EditText中输入“@”后,应显示符号电话联系人。 [英] In EditText After typing '@' symbol phone contacts should be displayed..

查看:89
本文介绍了在EditText中输入“@”后,应显示符号电话联系人。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有显示联系人的代码,但我发现很难在@符号后显示联系人.Kindly帮助...

公共类AutoCompleteTextViewActivity扩展活动{

String []结果;

String [] datacols = new String [] {

ContactsContract.CommonDataKinds.Phone._ID,

ContactsContract.CommonDataKinds。电话.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()&&我<计数;游标

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







}







}

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



}



}

推荐答案

实现TextChanged侦听器并在OnTextChange方法中设置适配器。
Implement TextChanged listener and set your Adapter in OnTextChange method.


这篇关于在EditText中输入“@”后,应显示符号电话联系人。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆