与collections.sort绑定不匹配(Bound Mismatch with collections.sort)
我有一个具有sqlite DB的应用程序,其内容被放入arraylist并可通过列表视图查看。 我的问题是我无法按字母顺序获取该项目。 我已经实现了
Collections.sort()
但是收到了Bound Mismatch错误。 有任何想法吗错误:
绑定不匹配:类型
Collections
的泛型方法sort(List<T>)
不适用于参数(ArrayList<LoginDetails>)
。 推断类型LoginDetails
不是有界参数的有效替代<T extends Comparable<? super T>>
<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; } }
I have a application that has a sqlite DB whos content is put into an arraylist and viewable through a list view. My issue is that I am unable to get the item in alphabetical order. I have implemented
Collections.sort()
but receive a Bound Mismatch error. any ideasError:
Bound mismatch: The generic method
sort(List<T>)
of typeCollections
is not applicable for the arguments(ArrayList<LoginDetails>)
. The inferred typeLoginDetails
is not a valid substitute for the bounded parameter<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. }
LoginDetails:
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; } }
原文:https://stackoverflow.com/questions/11651120
相关问答
更多-
hadoop 运行问题[2021-09-25]
解决方案: 1. 格式化namenode: # hadoop namenode -format 2. 重新启动hadoop# sh stop-all.sh# sh start-all.sh 3. 查看后台进程# jps13508 NameNode11008 SecondaryNameNode14393 Jps11096 JobTracker此时namenode启动 4. 运行# hadoop fs -ls12/01/31 14:04:39 INFO security.Groups: Group mappin ... -
你真的需要一个更好的“大”的定义。 “大”是一个愿望,还是你的营销部门*认为他们会拥有硬数据? 如果你可以使用简单的组件来做到这一点,那就做吧。 Cassandra和Hadoop之类的软件既不容易安装(特别是后者)或开发; 那些能够有效开发这样的应用程序的开发人员将非常昂贵且难以雇佣。 所以我想说,首先使用您最喜欢的“传统”数据库和适当的高可用性解决方案,然后等待,直到您接近极限(您可以始终测量实际应用程序的限制位置,一旦建立你有一个性能测试系统)。 请记住,堆栈溢出使用非常传统的组件,只需使用少量的商品硬 ...
-
任何类似于Apache Hadoop的测试框架/解决方案?(Any tested Frameworks/Solutions similar to Apache Hadoop?)[2022-12-14]
也许。 但是他们中没有一个会在测试中接近hadoop的真实世界体验。 像Facebook和雅虎这样的公司正在付钱来规模hadoop,我也知道没有类似的开源项目值得期待。 Maybe. But none of them will have anywhere near the testing a real world experience that hadoop does. Companies like facebook and yahoo are paying to scale hadoop and I kn ... -
假设zipIn是java.util.zip.ZipInputStream ,你不应该迭代地调用getNextEntry而不是读取字节吗? I resolved this issue after doing some changes in my code. In the first part of code, I was trying to unzip all the zip files whereas I should have access the spilts. Hadoop basic, which ...
-
在Hadoop中实现故障注入有哪些解决方案[关闭](What are the solutions to implementing the fault-injection in Hadoop [closed])[2022-01-03]
Hadoop实际上有一个故障注入框架。 看到这个 。 Hadoop actually has a fault injection framework. See this. -
点击此链接,在ubuntu上安装hadoop 0.23.9 。 但是对于hadoop 2.2.0也是如此。 尝试一下 Follow this link for hadoop 0.23.9 installation on ubuntu. But is same for hadoop 2.2.0. try it
-
请参阅org.apache.hadoop.examples.Sort 使用map / reduce并不是非常简单。 它涉及获取数据的直方图并使用TotalOrderPartitioner 。 或者,您可以使用Hive或Pig,它具有内置的排序功能。 See org.apache.hadoop.examples.Sort This is not super-straightforward to do using map/reduce. It involves taking a histogram of you ...
-
在启动项目中注册所有内容实际上是一件好事。 这个常见的地方称为组合根 ,它允许您最小化项目之间的引用数量,如此处所述。 你应该防止的另一件事是让你的代码(除了你的组合根之外的任何东西)依赖于DI库或对你的DI库的抽象。 因此,不要从构造函数内部调用Resolve ,而是将类的任何依赖项注入到该类的构造函数中。 例: public class Account { private readonly IEmailer emailer; public Account(IEmailer emaile ...
-
如果你正在使用cloudera发行版,那么它很可能在/usr/lib/hadoop ,否则它可能在任何地方(由你的系统管理员决定)。 您可以使用一些技巧来尝试找到它: locate hadoop-env.sh (假设已经安装了locate并且最近已经运行了updatedb) 如果你运行它的机器正在运行hadoop服务(例如数据节点,作业跟踪器,任务跟踪器,名称节点),那么你可以执行一个进程列表和grep for hadoop命令: ps axww | grep hadoop ps axww | grep h ...
-
这里有很好的解释。 https://hadoopi.wordpress.com/2013/05/27/understand-recordreader-inputsplit/ 而且在这里 https://github.com/apache/hadoop/blob/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/L ...