Multiple selectable GridView

后端 未结 3 1915
感情败类
感情败类 2021-02-06 06:18

OK, so I think I\'ve exhausted searching for this question, and it\'s either that I\'m totally missing something or nobody else has tried to create a GridView (showing images) w

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-06 07:14

    Just draw a checkbox onto the cell's bitmap when selected. Draw the original when toggle unchecked.

      private Bitmap drawCheck(Bitmap bmp)
      {
       Bitmap bmChecked = Bitmap.createBitmap(bmp.getWidth(),     bmp.getHeight(), bmp.getConfig());
       Bitmap check = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.upcheck);
       Canvas canvas = new Canvas(bmChecked);
    
       canvas.drawBitmap(bmp, 0, 0, null);
       canvas.drawBitmap(check, 0, 0, null); 
       return bmChecked;
      }
    

提交回复
热议问题