public View getView(int position, View convertView, ViewGroup parent) {
Button btn;
if (convertView == null) { // if it's not recycled, initialize some
// attributes
btn = new Button(mContext);
KeypadButton keypadButton = mButtons[position];
switch(keypadButton.mCategory)
{
case MEMORYBUFFER:
btn.setBackgroundResource(R.drawable.keypadmembuffer1);
break;
case CLEAR:
btn.setBackgroundResource(R.drawable.keypadclear1);
break;
case NUMBER:
btn.setBackgroundResource(R.drawable.keypad1);
break;
case OPERATOR:
btn.setBackgroundResource(R.drawable.keypadop1);
break;
case OTHER:
btn.setBackgroundResource(R.drawable.keypadother1);
break;
case RESULT:
btn.setWidth(8000);
btn.setBackgroundResource(R.drawable.keypadresult1);
break;
case DUMMY:
btn.setBackgroundResource(R.drawable.appvertical1);
break;
default:
btn.setBackgroundResource(R.drawable.keypad1);
break;
}
// Set OnClickListener of the button to mOnButtonClick
if(keypadButton != KeypadButton.DUMMY)
btn.setOnClickListener(mOnButtonClick);
else
btn.setClickable(false);
// Set CalculatorButton enumeration as tag of the button so that we
// will use this information from our main view to identify what to do
btn.setTag(keypadButton);
} else {
btn = (Button) convertView;
}
btn.setText(mButtons[position].getText());
return btn;
}
画面でスクロールを使用するたびに、最初の行のボタンが最後の行のボタンと混同されます。助けてください 。私はアンドロイドが初めてです。どうしたらいいのかわからない?? contextView の使用に関する知識は非常に限られています。if else ブロックを削除すると修正できますか。