0

我正在使用 androidimageloader.com 并且当图像加载到列表中时会出现一些闪烁,这与使用它的演示和应用程序非常不同。我在应用程序类中有 imageLoader,但不明白为什么它会闪烁。这些图像是用户的 Facebook 个人资料图片。什么会导致这种情况?这是我的适配器:

public class FriendAdapter extends BaseAdapter {
    private Typeface tf;
    LayoutInflater inflater;
    private String[] nameEvents;
    private String[] urls;
    private ArrayList<Friend> friends;
    ImageManager imageManager;
    ImageTagFactory imageTagFactory;

    public FriendAdapter(Activity activity, ArrayList<Friend> friends) {
        this.friends = friends;
        setData(this.friends);
        tf = Typeface.createFromAsset(activity.getAssets(),
                "fonts/Roboto-Condensed.ttf");
        inflater = (LayoutInflater) activity
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        imageManager = BuzzbabaApplication.getImageLoader();
        imageTagFactory = new ImageTagFactory(activity, R.drawable.no_pic_icon);
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        FriendView fView;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.friend_layout, null);
            fView = new FriendView();
            fView.name = (TextView) convertView.findViewById(R.id.friendName);
            fView.name.setTypeface(tf);
            fView.pic = (ImageView) convertView.findViewById(R.id.profilePic);
            convertView.setTag(fView);
        } else {
            fView = (FriendView) convertView.getTag();
        }
        fView.name.setText(nameEvents[position]);
        // HomeScreen.imageLoader.DisplayImage(urls[position], fView.pic);
        ((ImageView) fView.pic).setTag(imageTagFactory.build(urls[position]));
        imageManager.getLoader().load(fView.pic);
        return convertView;
    }

    public void setData(ArrayList<Friend> friends) {
        nameEvents = new String[friends.size()];
        urls = new String[friends.size()];
        int index = 0;
        for (Friend f : friends) {
            String pos = f.getName();
            int num = f.getNumEvents();
            if (num == 1) {
                pos = pos + "\n" + num + " event";
            } else {
                pos = pos + "\n" + num + " events";
            }
            nameEvents[index] = pos;
            urls[index] = f.getPictureURL();
            index++;
        }
    }

    static class FriendView {
        TextView name;
        ImageView pic;
    }

    public int getCount() {
        return friends.size();
    }

    public Object getItem(int position) {
        return position;
    }

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

}
4

0 回答 0