我在尝试编译时遇到此错误。这曾经在我使用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);
联系人类如下所示,这是我将返回的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;
}
}
请让我知道我哪里出错。
答案 0 :(得分:0)
您需要创建一个SimpleAdapter,可以从ArrayAdapter,BaseAdapter扩展,...