图像未在第一次完全加载,它在每次滚动后加载

时间:2014-09-18 04:39:25

标签: android

第一次没有加载在gridview中的图像,加载了一些图像,滚动后加载了一些图像,下一次滚动后加载了一些其他图像......帮助我们!!!! 提前致谢... 这是我的代码和截图


enter image description here

代码:

options = new DisplayImageOptions.Builder()
                .showImageOnLoading(R.drawable.logo_home3)
                .showImageForEmptyUri(R.drawable.image_for_empty_url)
                .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true)
                .bitmapConfig(Bitmap.Config.RGB_565).build();

// options = new DisplayImageOptions.Builder()
                // .showStubImage(R.drawable.logo_home3)
                // .showImageForEmptyUri(R.drawable.image_for_empty_url)
                // .cacheInMemory().cacheOnDisc().build();

imageAdapter = new ImageAdapter(this, 0, folderdetails);
gridView.setAdapter(imageAdapter);

gridView.setOnItemClickListener(new OnItemClickListener() {

    @Override
    public void onItemClick(AdapterView<?> arg0, View gridlistview, int position, long arg3) {

        ImageDetails pojo = (ImageDetails) folderdetails.get(position);
        Editor editor = application.getPrefEditor();
        editor.putString("FolderImg", pojo.getFoldername());
        editor.commit();

        moveNextPagewitoutfinish(MultiPhotoSelectActivity.class);

    }
});


public class ImageAdapter extends BaseAdapter {

    ArrayList<ImageDetails> mList;
    ArrayList<String> mCheck;
    LayoutInflater mInflater;
    Context mContext;
    private int resource;

    private SparseBooleanArray mSelectedItemsIds;

    public ImageAdapter(Context context, int resource, ArrayList<ImageDetails> imageList) {
        mContext = context;
        mInflater = LayoutInflater.from(mContext);
        mList = new ArrayList<ImageDetails>();
        this.mList = imageList;
        getvalue = imageList;
        mSelectedItemsIds = new SparseBooleanArray();
    }

    @Override
    public int getCount() {
        return folderdetails.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    public void toggleSelection(int position) {
        selectView(position, !mSelectedItemsIds.get(position));
    }

    public void removeSelection() {
        mSelectedItemsIds = new SparseBooleanArray();
        notifyDataSetChanged();
    }

    public void selectView(int position, boolean value) {
        if (value)
            mSelectedItemsIds.put(position, value);
        else
            mSelectedItemsIds.delete(position);

        notifyDataSetChanged();
    }

    public int getSelectedCount() {
        return mSelectedItemsIds.size();// mSelectedCount;
    }

    public SparseBooleanArray getSelectedIds() {
        return mSelectedItemsIds;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.gallery_picker_item, null);
        }

        convertView.setBackgroundColor(mSelectedItemsIds.get(position) ? 0x9934B5E4 : Color.TRANSPARENT);

        final ImageView imageView = (ImageView) convertView.findViewById(R.id.thumbnail);
        final TextView text = (TextView) convertView.findViewById(R.id.title);
        final TextView imgcount = (TextView) convertView.findViewById(R.id.count);

        imgcount.setText(mList.get(position).getCount() + "");
        text.setText(mList.get(position).getFoldername());
        imageLoader.displayImage("file://" + mList.get(position).getFilepath(), imageView, options, null);

        return convertView;
    }
}

0 个答案:

没有答案