我有传递给标签的类别Arraylist。标签获取类别名称并进行设置。如何对类别Arraylist进行排序?
private List<Category> mCategories;
private LayoutInflater mInflater;
public LeftMenuAdapter(Context context, List<Category> categories) {
mCategories = categories;
mInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
Category category = mCategories.get(position - 3);
holder.label.setText(category.getName());
分类等级:
public class Category implements Parcelable {
private List<String> images;
private String name;
public List<String> getImages() {
return this.images;
}
public void setImages(List<String> images) {
this.images = images;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
protected Category(Parcel in) {
if (in.readByte() == 0x01) {
images = new ArrayList<String>();
in.readList(images, String.class.getClassLoader());
} else {
images = null;
}
name = in.readString();
}
@Override
public int describeContents() {
return 2;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
if (images == null) {
dest.writeByte((byte) (0x00));
} else {
dest.writeByte((byte) (0x01));
dest.writeList(images);
}
dest.writeString(name);
}
public static final Parcelable.Creator<Category> CREATOR = new Parcelable.Creator<Category>() {
@Override
public Category createFromParcel(Parcel in) {
return new Category(in);
}
@Override
public Category[] newArray(int size) {
return new Category[size];
}
};
}
我使用的比较,但它说Cannot resolve symbol sort
。我怎样才能按名称对类别进行排序?
你可以发表你的 '类别' 类,它具有实现比较? –
分类类是不同的,我问的类别也不同,看你有没有使用名单不是名单 ... !! –
您想按类别名称对列表进行排序吗? –