1

カスタムアダプターとレイアウトアイテムを使用してリストビューを実装しました。その中で私は複雑な論理を持っています。リストビューが最初に読み込まれると、ロジックで正しいレコードが表示されます。しかし、下にスクロールして上にスクロールすると、ロジックの意味が変わり、データが更新されます。

だから私はリストビューのバインド時にそのロジックを一度だけ実行したい..

誰でも私を助けることができますか?

前もって感謝します。

4

1 に答える 1

0
public View getView(final int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    final ViewHolder holder;

    if (convertView == null) {
        holder = new ViewHolder();

        convertView = mInflater.inflate(R.layout.shopping_cartcell_layout,
                null);
        holder.product_name = (TextView) convertView
                .findViewById(R.id.product_name);
        holder.base_price_tv = (TextView) convertView
                .findViewById(R.id.base_price_view);



        convertView.setTag(holder);

    } else {
        holder = (ViewHolder) convertView.getTag();

    }

    // here you can set your value to your view one example like below
            // if you have any arrylist then get your data and set to your view
            // for example "PRODUCTLIST" is your array list in which you store products
            // see how to set it

         if(PRODUCTLIST.get(position).getproductname !=null){

               holder.product_name.settext(PRODUCTLIST.get(position).getproductname);
              }

         if(PRODUCTLIST.get(position).getproductbaseprice !=null){

          holder.base_price_tv.settext(PRODUCTLIST.get(position).getproductbaseprice);

           }
        return convertView;
于 2012-06-29T13:39:26.947 に答える