我有一个应用程序,它有一个 sqlite 数据库,其内容被放入一个数组列表并可以通过列表视图查看。我的问题是我无法按字母顺序获取该项目。我已经实现Collections.sort()
但收到一个 Bound Mismatch 错误。有任何想法吗
错误:
sort(List<T>)
绑定不匹配:类型的泛型方法Collections
不适用于 arguments (ArrayList<LoginDetails>)
。推断的类型LoginDetails
不是有界参数的有效替代品<T extends Comparable<? super T>>
private ListView loginList;
private Button webLogin;
private ListAdapter loginListAdapter;
private ArrayList<LoginDetails> loginArrayList;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login_listview);
loginList = (ListView)
findViewById(R.id.loginlist);
loginList.setOnItemClickListener(this);
webLogin = (Button)
findViewById(R.id.button3);
webLogin.setOnClickListener(this);
loginArrayList = new ArrayList<LoginDetails>();
loginListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, populateList());
loginList.setAdapter(loginListAdapter);
Collections.sort(loginArrayList ); //Bound mismatch error is here.
}
登录详细信息:
public class LoginDetails {
private String sName;
private String wUrl;
private String uName;
private String pWord;
public String getsName() {
return sName;
}
public void setsName(String sName) {
this.sName = sName;
}
public String getwUrl() {
return wUrl;
}
public void setwUrl(String wUrl) {
this.wUrl = wUrl;
}
public String getuName() {
return uName;
}
public void setuName(String uName) {
this.uName = uName;
}
public String getpWord() {
return pWord;
}
public void setpWord(String pWord) {
this.pWord = pWord;
}
}