1

我已经使用自定义适配器和布局项实现了列表视图。我有一个复杂的逻辑。当列表视图首先加载时,它会根据我的逻辑显示正确的记录。但是当我向下滚动而不是向上滚动时,它改变了我的逻辑含义并更新了数据。

所以我只想在listview绑定时运行一次该逻辑..

谁能帮我?

提前致谢。

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 回答