-2

滚动列表上的数据被更改,我已将这些数据添加到相对布局中。

@Override
    public View getView(int paramInt, View paramView,ViewGroup paramViewGroup) {
        View localView = paramView;
        MyCustomHolder holder = null;
        if (localView == null) {
            LayoutInflater inflater = (LayoutInflater) CopyOfHistory.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            localView = inflater.inflate(R.layout.copyhistorylist, null);
            holder = new MyCustomHolder();
            holder.coffeeShopName = (TextView) localView.findViewById(R.id.hlcoffeeshopname);
            holder.coffeeshopid = (TextView) localView.findViewById(R.id.hlcoffeeshopid);
            localView.setTag(holder);
            int looplimit = Integer.parseInt(TAG_TOTAL.get(paramInt));
            for (int i = 0; i < looplimit; i++) {
                Log.e("loop", String.valueOf(looplimit));
                final ImageView imageView = new ImageView(CopyOfHistory.this);
                if (i < Integer.parseInt(TAG_COUNT.get(paramInt))) {
                    imageView.setImageDrawable(getResources().getDrawable(R.drawable.ii));
                } else {
                    imageView.setImageDrawable(getResources().getDrawable(R.drawable.iii));
                }
                imageView.setTag(i);
                layout = (RelativeLayout) localView.findViewById(R.id.hlrlayout);
                RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(30,30);
                params.setMargins(i*40, 0, 0, 0);
                imageView.setLayoutParams(params);
                layout.setTag(paramInt);
                layout.addView(imageView);
                //holder.relativeLayout = new RelativeLayout();


            }

        } else {
            holder = (MyCustomHolder) localView.getTag();
   layout.getTag(paramInt);

        }
        holder.coffeeShopName.setText(TAG_COFFEESHOP_NAME.get(paramInt));
        holder.coffeeshopid.setText(TAG_ID.get(paramInt));


        holder.coffeeShopName.setFocusable(false);
        holder.coffeeShopName.setFocusableInTouchMode(false);
        return localView;

    }
4

1 回答 1

1

你应该删除检查 if(localView == null) { }else { }

只需删除它,问题就会解决

于 2013-08-20T11:59:57.257 回答