我有按鈕的GridView控件,我需要改變的背景和可點擊一些按鈕,它可以很好地用於所有,但不是第一位:GridView的第一項工作不
public View getView(int position, View convertView, ViewGroup parent) {
Button btn;
if (convertView == null) {
btn = new Button(mContext);
btn.setLayoutParams(new GridView.LayoutParams(44,44));
btn.setPadding(0,0,0,0);
}
else {
btn = (Button) convertView;
}
btn.setId(position);
bottoni[position] = btn;
//abilito o disabilito caselle
if (mossa == 1){
btn.setBackgroundColor(Color.parseColor("#C85A17"));
btn.setClickable(true);
}
else {
if (statobtn[position] == "A") {
btn.setBackground(getResources().getDrawable(R.drawable.semi));
btn.setClickable(true); }
if (testobtn[position] != "") {
btn.setBackground(getResources().getDrawable(R.drawable.fiorebianco));
btn.setClickable(false); }
}
btn.setOnClickListener(new MyOnClickListener(position,btn));
return btn;
}
什麼想法?
我開始與100鍵eneabled AFER首先我需要啓用不僅關係到按鈕按下幾個按鈕,但是第一個按鈕總是enebled ...
我們可以看到'getView'的休息嗎? – gunar