DoRemix 2014-12-30 05:36 采纳率: 0%
浏览 1076

androi的 listview 做加减算法会出现顿卡

    @SuppressLint("InflateParams")
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        final ViewHolder holder;
        if(Modellist.get(position)== null){
             convertView = inflater.inflate(R.layout.taklist_item,null);
             holder =new ViewHolder();
             holder.button2 = (Button)convertView.findViewById(R.id.tot_tv_add);
             holder.view = (TextView)convertView.findViewById(R.id.tot_tv_number);
             holder.view3 = (TextView)convertView.findViewById(R.id.tot_tv_price);
             holder.view2 = (TextView)convertView.findViewById(R.id.tot_tv_name);
             Modellist.put(position, convertView);
             holder.button2.setTag(position);
             convertView.setTag(holder);
         }else {
            convertView = Modellist.get(position);
            holder= (ViewHolder)convertView.getTag();
         }
        holder.view2.setText(data.get(position));
        holder.view3.setText(data.get(position));

        holder.button2.setOnClickListener(new OnClickListener() {
            private Model model;
            @Override
            public void onClick(View v) {   
                model = new Model();
                model.numcount = Integer.valueOf(holder.view.getText().toString().trim())+1;
                holder.view.setText(String.valueOf(model.getNumcount()));
            }
        });
        //System.out.println("getview "+position + " convertView" + convertView);
        return convertView;
    }

这样写的确是可以做到数据不重复,但是会出现一个现象就是在上加载多了以后点击加号回出现界面不能刷新问题,

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何解决ldsc的这条报错/index error
    • ¥15 VS2022+WDK驱动开发环境
    • ¥30 关于#java#的问题,请各位专家解答!
    • ¥30 vue+element根据数据循环生成多个table,如何实现最后一列 平均分合并
    • ¥20 pcf8563时钟芯片不启振
    • ¥20 pip2.40更新pip2.43时报错
    • ¥15 换yum源但仍然用不了httpd
    • ¥50 C# 使用DEVMOD设置打印机首选项
    • ¥15 麒麟V10 arm安装gdal
    • ¥20 OPENVPN连接问题