2012-03-05 33 views
1
  ContentResolver cr = getContentResolver(); 
      Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, 
        null, null, null, null); 
      if (cur.getCount() > 0) { 
      while (cur.moveToNext()) { 
       String id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID)); 
      String name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); 

      c_Name.add(name); 

       } } 







      name_Val = (String[]) c_Name.toArray(new String[c_Name.size()]); 
      //phone_Val= (String[]) c_Number.toArray(new String[c_Name.size()]); 
      ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,name_Val); 
      txtPhoneName.setAdapter(adapter); 
+2

以上所有代码都在onCreate {} – denza 2012-03-05 14:01:52

+3

正如我在调试我按照代码,直到txtPhoneName.setAdapter(适配器)和ArrayAdapter适配器填充的联系人开始{null,“Name1”,“Name2”。 ..}但是当涉及到autocompletetextView它不显示任何东西,如果insead我使用固定的String [] d = {“NAME1”,“Name2”,“name3”}它绑定他们就好了 – denza 2012-03-05 14:10:26

回答

0

为什么绑定到ArrayList?您可以使用SimpleCursorAdapter直接绑定到cur。

什么是autocompletetextView?

很难分辨究竟发生了什么,因为这么多应用程序缺失。

此外,你究竟想要做什么?可能有一个更简单的方法来做到这一点。

相关问题