tag:blogger.com,1999:blog-2865777313825124004.post4908437612947002729..comments2024-03-12T14:37:46.024-07:00Comments on Android Coding: Sort the file list in order, by implementing Comparator.Erikhttp://www.blogger.com/profile/04983894331825656853noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-2865777313825124004.post-66371896393874688212012-07-12T00:07:23.035-07:002012-07-12T00:07:23.035-07:00The method sort(T[], Comparator) in the type Array...The method sort(T[], Comparator) in the type Arrays is not applicable for the arguments (List, Comparator)<br /><br />i get this error if i write arrays.sort(fileList, filecomparator) :( i have removed fifos=files.Anonymoushttps://www.blogger.com/profile/05618036168984465364noreply@blogger.comtag:blogger.com,1999:blog-2865777313825124004.post-71818239885688554792012-07-12T00:05:38.684-07:002012-07-12T00:05:38.684-07:00so u mean i should be writing Arrays.sort(fileList...so u mean i should be writing Arrays.sort(fileList, filecomaprator)??? <br />but i have already declared fifos=files in my code..Anonymoushttps://www.blogger.com/profile/05618036168984465364noreply@blogger.comtag:blogger.com,1999:blog-2865777313825124004.post-62374709733593756922012-07-11T06:24:56.386-07:002012-07-11T06:24:56.386-07:00It seem that you sort fifos, not fileList.It seem that you sort fifos, not fileList.And.codinghttps://www.blogger.com/profile/01269407937760285746noreply@blogger.comtag:blogger.com,1999:blog-2865777313825124004.post-27727863297437737612012-07-11T02:55:00.308-07:002012-07-11T02:55:00.308-07:00hii ive tried sorting using the above code by usin...hii ive tried sorting using the above code by using a button but it doesnt work wen i click on the sort bttn plz hlp..<br />public void addListenerOnSorting() {<br /> final ArrayAdapter directoryList<br /> = new ArrayAdapter(this, android.R.layout.simple_list_item_1, fileList);<br /> setListAdapter(directoryList); <br /> sorting=(Button) findViewById(R.id.sort);<br /> <br /> sorting.setOnClickListener(new OnClickListener() {<br /> <br /> <br /> public void onClick(View v) {<br /> <br /> Arrays.sort(fifos, filecomparator);<br /> <br /> directoryList.notifyDataSetChanged();<br /> <br /> }<br /> Comparator filecomparator = new Comparator(){<br /> public int compare(File file1, File file2) {<br /> return String.valueOf(file1.getName()).compareTo(file2.getName());<br /> <br /> }<br /> }; <br /> });Anonymoushttps://www.blogger.com/profile/05618036168984465364noreply@blogger.com