排序实例

1.按字母排序

List activities=pm.queryIntentActivities(startupIntent,0);

Collections.sort(activities, new Comparator() {
    @Override
    public int compare(ResolveInfo a, ResolveInfo b) {
        PackageManager pm=getActivity().getPackageManager();
        return String.CASE_INSENSITIVE_ORDER.compare(a.loadLabel(pm).toString(),b.loadLabel(pm).toString());
    }
});

你可能感兴趣的:(java)