ContactsAdapter的部分。忘记上了。 sorry
package irdc.ex05_09;import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.provider.Contacts;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.TextView;public class ContactsAdapter extends CursorAdapter
{
  private ContentResolver mContent;  public ContactsAdapter(Context context, Cursor c)
  {
    super(context, c);
    mContent = context.getContentResolver();
  }  @Override
  public void bindView(View view, Context context, Cursor cursor)
  {
    /* 取得通訊錄人員的名字 */
    ((TextView) view).setText(cursor.getString(cursor
        .getColumnIndexOrThrow(Contacts.People.NAME)));
  }  @Override
  public View newView(Context context, Cursor cursor, ViewGroup parent)
  {
    final LayoutInflater inflater = LayoutInflater.from(context);
    final TextView view = (TextView) inflater.inflate(
        android.R.layout.simple_dropdown_item_1line, parent, false);
    view.setText(cursor.getString(cursor
        .getColumnIndexOrThrow(Contacts.People.NAME)));
    return view;
  }  @Override
  public String convertToString(Cursor cursor)
  {
    return cursor.getString(cursor.getColumnIndexOrThrow(Contacts.People.NAME));
  }  @Override
  public Cursor runQueryOnBackgroundThread(CharSequence constraint)
  {
    if (getFilterQueryProvider() != null)
    {
      return getFilterQueryProvider().runQuery(constraint);
    }    StringBuilder buffer = null;
    String[] args = null;
    if (constraint != null)
    {
      buffer = new StringBuilder();
      buffer.append("UPPER(");
      buffer.append(Contacts.ContactMethods.NAME);
      buffer.append(") GLOB ?");
      args = new String[]
      { constraint.toString().toUpperCase() + "*" };
    }
    return mContent.query(Contacts.People.CONTENT_URI,
        EX05_09.PEOPLE_PROJECTION, buffer == null ? null : buffer.toString(),
        args, Contacts.People.DEFAULT_SORT_ORDER);
  }
}

解决方案 »

  1.   

    我发现LZ发现了android开发范例大全里面好几个问题了是吧?
      

  2.   

    发现这个东西
    http://wang-peng1.javaeye.com/blog/564284基本上来说在android 2.0中是要将
    import android.provider.Contacts;
    import android.provider.Contacts.People;
    替换成
    import android.provider.ContactsContract;
    import android.provider.ContactsContract.PhoneLookup;但是那个Contacts.People.NUMBER怎么替换还是不明白http://developer.android.com/reference/android/provider/ContactsContract.Data.html
    说Data kindsData is a generic table that can hold any kind of contact data. The kind of data stored in a given row is specified by the row's MIMETYPE value, which determines the meaning of the generic columns DATA1 through DATA15. For example, if the data kind is Phone.CONTENT_ITEM_TYPE, then the column DATA1 stores the phone number, but if the data kind is Email.CONTENT_ITEM_TYPE, then DATA1 stores the email address. Sync adapters and applications can introduce their own data kinds.ContactsContract defines a small number of pre-defined data kinds, e.g. ContactsContract.CommonDataKinds.Phone, ContactsContract.CommonDataKinds.Email etc. As a convenience, these classes define data kind specific aliases for DATA1 etc. For example, Phone.NUMBER is the same as Data.DATA1. 
    希望高人帮忙分析一下要怎么改
      

  3.   

    最好把 你的sdk版本换成 和书中的一致 
    因为sdk没个版本都有变动
      

  4.   

    恩~实现例子的话,换回1.5当然可以。但是我现在想解决在sdk2.0以上的版本中,如何获取contact Number。
    This is a question >_<