Android 简单适配器

Android Simple Adapter

我在尝试编译时遇到此错误。这曾经在我使用 sdk 23 时有效,但现在我已经升级到 26,我无法编译它。

Error:(41, 13) error: cannot find symbol class SimpleAdapter

这是我的代码,用于从网站获取联系人列表并在列表视图中显示它们。

public class ContactsActivity extends Activity {
private SimpleAdapter adpt;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_contacts);

    adpt  = new SimpleAdapter(new ArrayList<Contact>(), this);
    adpt.setStyle(R.layout.contact_list_item);
    ListView lView = (ListView) findViewById(R.id.listview_contacts);

联系人 class 如下,这是我返回的 xml 返回后的内容。

public class Contact implements Serializable {

private String Name;
private String Phone;
private String Cell;
private String Email;
private String Address;
private String Work;

public Contact() {
    super();
}
public Contact(String name, String phone, String cell, String email, String address,String work) {
    super();
    this.Name = name;
    this.Phone = phone;
    this.Cell = cell;
    this.Email = email;
    this.Address = address;
    this.Work = work;
}

public String getName() {
    return Name;
}

public void setName(String name) {
    this.Name = name;
}

public String getPhone() {
    return Phone;
}

public void setPhone(String phone) {
    this.Phone = phone;
}

public String getCell() {
    return Cell;
}

public void setCell(String cell) {
    this.Cell = cell;
}

public String getEmail() {
    return Email;
}

public void setEmail(String email) {
    this.Email = email;
}

public String getAddress() {
    return Address;
}

public void setAddress(String address) {
    this.Address = address;
}

public String getWork() {
    return Work;
}

public void setWork(String work) {
    this.Work = work;
}

}

请让我知道哪里出错了。

您需要创建一个 SimpleAdapter,可以从 ArrayAdapter、BaseAdapter 扩展...