如何按字母顺序对名称的arylylist进行排序?

时间:2017-12-09 22:09:56

标签: android android-layout listview android-arrayadapter

我一直在研究按字母顺序排列调用者名称的数组列表。 不确定如何应用集合或其他任何东西,这将是理想的?关于如何去做的任何想法? 我在网上看过几个例子,但似乎没有任何帮助。

不确定它对我的代码是如何适用的。 我的代码如下:

y

3 个答案:

答案 0 :(得分:1)

让调用者实现Comparable,然后调用Collections.sort(调用者)

像这样:

System.Timers.Timer

然后:

Function IsPresentationOpen(Name As String) As Boolean
    Dim codePres As Presentation
    On Error Resume Next
    Set codePres = Application.Presentations.Item(Name)
    IsWorkBookOpen = (Not codePres Is Nothing)

End Function

Sub Run_Macro()

    Dim BriefingTemplate As Presentation
    Set BriefingTemplate = Application.ActivePresentation

'Open Joe's Code Workbook
    Dim xRet As Boolean
    xRet = IsPresentationOpen("CODE.potm")
    If xRet Then
    Else
        Presentations.Open "Direcory\CODE.potm"
    End If

'Run Macro
    BriefingTemplate.Activate                            '<<This is the line w/ the error
    Application.Run ("'CODE.potm'!Macro"), BriefingTemplate


End Sub

Sub a_RunAll_PM(BriefingTemplate As Presentation)

BriefingTemplate.Activate

  Call a_Scorecards_PM
  Call CurrentTemps_PM
  Call RadarSat_PM
  Call Severe_PM
  Call Day1_PM
  Call Day2
  Call JetStream_PM
  Call Operational_Impact_PM
  Call D1_Headlines_PM
  Call D2_Headlines
End Sub

Sub a_Scorecards_PM()
   Dim oPic As Shape
    Set oPic = ActivePresentation.Slides(1).Shapes.AddPicture( _
    FileName:="H:\Weather Briefs\Daily Ops Scorecards\SWA_Page_1.jpg", _
    LinkToFile:=msoFalse, _
    SaveWithDocument:=msoTrue, Left:=0, Top:=0, _
    Width:=720, Height:=540)

    ActivePresentation.Slides(1).Copy
    ActivePresentation.Slides.Paste 24

End Sub

答案 1 :(得分:0)

您可以使用此代码按字母顺序对列表进行排序:

Collections.sort(list);

答案 2 :(得分:0)

我从here找到答案。

Collections.sort(list, new Comparator<String>() {
    @Override
    public int compare(String s1, String s2) {
        return s1.compareToIgnoreCase(s2);
    }
});