Reputation: 46
Hello I am using this to load images from SD card. Everything works well except that I wish to reverse the order of the list. I know this is rather vague but hopefully someone might have come across this adapter and can help me. https://github.com/thest1/LazyList/tree/master/src/com/fedorvlasov/lazylist
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
public class LazyAdapter extends BaseAdapter {
private final String[] data;
private static LayoutInflater inflater = null;
public ImageLoader imageLoader;
public LazyAdapter(Activity a, String[] d) {
// Declare variables
data = d;
inflater = (LayoutInflater) a
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
imageLoader = new ImageLoader();
}
public int getCount() {
return data.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
@SuppressLint("InflateParams")
public View getView(int position, View convertView, ViewGroup parent) {
View vi = convertView;
if (convertView == null)
vi = inflater.inflate(R.layout.gridview_item, null);
// Locate the ImageView in item.xml
ImageView image = vi.findViewById(R.id.image);
// Capture position and set to the ImageView
imageLoader.DisplayImage(data[position], image);
return vi;
}
}
Upvotes: 0
Views: 81
Reputation: 716
Why not use a recycler view and glide? This library is outdated. To reverse order in a list, you should pass a list with data in reverse order to your adapter. Check this for your example: How do I reverse an int array in Java?
Upvotes: 1