OnClickListener not working for first item in GridView

前端 未结 7 1519
一向
一向 2020-12-03 02:54

I have a problem with creating a GridView-based calendar. Here is the Grid:

\"GridView

This

相关标签:
7条回答
  • 2020-12-03 03:52

    I had the same problem.Keeping the setLayoutParams inside the if(view == null) clause worked out. You dont have to sacrifice view recyling in that way.

    like :

     if(row == null){
       // inflate row
       row.setLayoutParams(params);
       //remaining code
     }else{
        holder = (ViewHolder)row.getTag();
     }
     // everything else
    

    I don't know why it works but it worked for me. I also noticed that all codes regarding the same issue in stackoverflow had also used setLayoutParams outside the if clause. This is my first time so i dont know if i can post this everywhere. Hope it helped .

    Source : Lot of trail and error .

    0 讨论(0)
提交回复
热议问题