0

名前、価格、製品画像の URL が記載されたアイテムのバッグリストがあります。https://github.com/nostra13/Android-Universal-Image-Loaderこのライブラリを使用 して、url からイメージビューをロードします。私が直面する問題は、リストビューで特定の行に画像が表示されないことです

public class BagAdapter extends BaseAdapter {
    int pos;

    Context MyContext;
    public boolean isCloseButtonAvailable;
    Object positionForCheck;
    ViewHolderForBag holder;

    public BagAdapter(Context _MyContext, boolean isavail) {

        MyContext = _MyContext;
        isCloseButtonAvailable = isavail;

    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub

        return BagList.getItemCount();
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View MyView = convertView;
        pos = position;
        positionForCheck = (Object) pos;
        if (convertView == null) {
            LayoutInflater li = (LayoutInflater) MyContext
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            MyView = li.inflate(R.layout.shoppingbagrow, null);
            holder = new ViewHolderForBag();
            holder.listitemimageView = (ImageView) MyView
                    .findViewById(R.id.listitemimageView);
            holder.name = (TextView) MyView
                    .findViewById(R.id.DescriptionTextView);
            holder.price = (TextView) MyView.findViewById(R.id.PriceTextView);
            holder.arrowimage = (ImageView) MyView
                    .findViewById(R.id.Arrowimagelistitem);
            holder.editimage = (ImageView) MyView.findViewById(R.id.editimage);
            holder.border = (ImageView) MyView
                    .findViewById(R.id.listitemimageView);

            MyView.setTag(holder);
        } else {
            holder = (ViewHolderForBag) MyView.getTag();
        }

        String producturl="";
        Typeface type= Typeface.createFromAsset(MyContext.getAssets(),"fonts/Helvetica.ttf");

        holder.name.setText("$"
                + BagList.getAllBaglistItems().get(pos).itemName);

        holder.price.setText("$"
                + BagList.getAllBaglistItems().get(pos).itemPrice);
        Double d=Double.parseDouble(BagList.getAllBaglistItems().get(pos).itemPrice.toString());

producturl=String.valueOf(BagList.getAllBaglistItems().get(pos).itemUrl.toString());



    holder.price.setText( String.format("%.2f", d) );
    holder.price.setTypeface(type, Typeface.BOLD);
    holder.name.setTypeface(type, Typeface.BOLD);
        holder.arrowimage.setImageResource(R.drawable.aero);

        ImageLoader imageLoader = ImageLoader.getInstance();
        imageLoader.init(ImageLoaderConfiguration.createDefault(MyContext));
        imageLoader.displayImage(producturl, holder.listitemimageView );

        holder.editimage.setTag(pos);

        if ((position + 1) % 3 == 0)
            holder.border.setVisibility(View.INVISIBLE);
        else
            holder.border.setVisibility(View.VISIBLE);
        if (isCloseButtonAvailable) {
            holder.editimage.setVisibility(View.VISIBLE);
            holder.editimage.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {

                    DatabaseAdapterForBag dbBag = new DatabaseAdapterForBag(
                            MyContext);
                    dbBag.open();

                    int posi = Integer.parseInt(v.getTag().toString());
                    dbBag.deleteFile(BagList.getAllBaglistItems().get(posi).itemSku);
                    dbBag.close();
                    BagList.deleteItem(posi);
                    notifyDataSetChanged();
                }
            });
        } else {
            holder.editimage.setVisibility(View.GONE);
        }
        return MyView;
    }

    public static class ViewHolderForBag {

        // public ImageView listitemimageView;
        public TextView name;
        public TextView price;
        public ImageView border;
        public ImageView arrowimage;
        public ImageView editimage;
        public ImageView listitemimageView;
    }
    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return BagList.getAllBaglistItems().get(position);
    }

    @Override
    public void notifyDataSetChanged() {

        super.notifyDataSetChanged();
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }


}

これは私のアダプター クラスです。

4

0 に答える 0