I'm using UniversalImageLoader Library to load images from server to gridView items.my Item's layout contain a RatingBar and I want to Sort Items By Rates when user touch sort button. in first time,items loaded randomly,is there any way to sort GridView Items Locally without getting query from server and fill the gridView again?
Thanks For Any Help
My ItemAdapter:
class ItemAdapter extends BaseAdapter implements AnimationListener{
@Override
public int getCount() {
return LogoUrl.length;
}
private class ViewHolder {
public TextView text;
public TextView text2;
public RatingBar rate;
public ImageView image;
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
final ViewHolder holder;
if (convertView == null) {
view = inflater.inflate(R.layout.frame, null);
holder = new ViewHolder();
holder.text = (TextView) view.findViewById(R.id.txtView1);
holder.text2 = (TextView) view.findViewById(R.id.txtView2);
holder.rate=(RatingBar) view.findViewById(R.id.rateBar);
holder.image = (ImageView) view.findViewById(R.id.img1);
view.setTag(holder);
} else
holder = (ViewHolder) view.getTag();
holder.text2.setText(text);
holder.text.setText(text);
holder.text.setSelected(true);
holder.rate.setRating(rate);
Loading = AnimationUtils.loadAnimation(getApplicationContext(),
R.anim.loading);
Loading.setAnimationListener(this);
holder.image.startAnimation(Loading);
imageLoader.displayImage(LogoUrl[position], holder.image, options, new SimpleImageLoadingListener() {
@Override
public void onLoadingComplete(Bitmap loadedImage) {
Animation anim = AnimationUtils.loadAnimation(getActivity(), R.anim.fade_in);
holder.image.setAnimation(anim);
anim.start();
}
});
return view;
}
0 comments:
Post a Comment