推 zxc190:adapter的getItem中設定背景顏色 03/12 15:49
推 chiel:adapter的getView()裡面 convertView.setBackgroundColor 03/13 00:19
→ chiel:(Color.BLACK or Color.WHITE); 03/13 00:20
昨天我嘗試:
TextView[] pixel = new TextView[900];
GridLayout gridLayout = (GridLayout) findViewById(R.id.gridLayout);
for(int i = 0;i<900;i++){
pixel[i] = new TextView(this);
gridLayout.addView(pixel[i]);
pixel[i].setBackgroundColor(Color.YELLOW);
}
但這樣子載入速度也是很慢。
會造成速度慢的原因是上面的程式碼產生過多的 View 嗎?
使用 getItem 的方法可以避免產生一堆 View?
謝謝
※ 編輯: noodleT 來自: 61.227.97.248 (03/13 11:29)
→ tails32100:在Adapter#getView()裡 去設View的background 03/13 14:07