我想知道如何对这个适配器进行排序:
private class ProductsListAdapter extends BaseAdapter {
public ProductsListAdapter() {
super();
}
public int getCount() {
return SingletonComparer.getInstance().getProducts().size();
}
public Object getItem(int position) {
return SingletonComparer.getInstance().getProducts().get(position);
}
public long getItemId(int position) {
return SingletonComparer.getInstance().getProducts().get(position).getId();
}
public View getView(int position, View convertView, ViewGroup parent) {
TextView textView = getGenericView();
textView.setText(SingletonComparer.getInstance().getProducts().get(position)
.getName());
TextView textView2 = getGenericView();
textView2.setText(""
+ SingletonComparer.getInstance().getProducts()
.get(position).getPrice());
TextView textView3 = getGenericView();
textView3.setText(SingletonData.getInstance().getBrandName(SingletonComparer.getInstance().getProducts().get(position)
.getBrandID()));
LinearLayout ll = new LinearLayout(getActivity());
ll.addView(textView, new LinearLayout.LayoutParams(0,
LayoutParams.WRAP_CONTENT, 1.0f));
ll.addView(textView2, 1, new LinearLayout.LayoutParams(0,
LayoutParams.WRAP_CONTENT, 1.0f));
ll.addView(textView3, 2, new LinearLayout.LayoutParams(0,
LayoutParams.WRAP_CONTENT, 1.0f));
ll.setId(SingletonComparer.getInstance().getProducts().get(position)
.getId());
return ll;
}
}
按领域
SingletonComparer.getInstance().getProducts()
.get(position).getPrice());
这个有可能?如果是,我该怎么做?