如何在lazyadapter中反转listview的顺序

qcbq4gxm  于 2021-07-11  发布在  Java
关注(0)|答案(1)|浏览(328)

你好,我用这个从sd卡加载图像。一切都很顺利,只是我想颠倒一下单子的顺序。我知道这是相当模糊,但希望有人可能会遇到这个适配器,可以帮助我。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;
    }
}
thigvfpy

thigvfpy1#

为什么不使用回收视图和滑翔?这个图书馆已经过时了。要反转列表中的顺序,应将包含数据的列表按相反顺序传递给适配器。请检查以下示例:如何在java中反转int数组?

相关问题