Getview Called multiple times in android

后端 未结 2 1078
醉话见心
醉话见心 2020-12-01 11:20

I am working on reuse of cell and currently i am working in getview method of adapter and i got one problem that my getview method called 9 times but it should call only 5 t

相关标签:
2条回答
  • 2020-12-01 11:47

    Make your listview height equal to fill_parent and try it again..

    0 讨论(0)
  • 2020-12-01 12:02

    Try like this...

    public View getView(int position, View convertView, ViewGroup viewgroup) 
    {   
    View view = convertView;
        ViewHolder holder=null;
    
        if(convertView==null)
          {  
                   view = inflater.inflate(R.layout.my_row_layout, viewgroup, false);
                  Log.d("Testing","View is nuLL");
                    holder.thumbnils  = (ImageView)view.findViewById(R.id.Thumbnils);
                         holder.hover =(ImageButton)view.findViewById(R.id.hover);
                        holder.title  =(TextView)view.findViewById(R.id.title);
                        holder.hoveroverlay  =(ImageView)view.findViewById(R.id.hoveroverlay);
                   view.setTag(holder);
                 }
             else
        {
            Log.d("Testing","view is not null");
    
            holder = (ViewHolder) view.getTag();
           }
    }
    
    0 讨论(0)
提交回复
热议问题