私のリスト行には、他のビューもあるチェックボックスが含まれています。チェックボックスをオンまたはオフにすると、関連するアクションリスナーが起動されません。以下は、getView() のコード スニペットです。見て、解決策を教えてください。
public View getView(int position, View convertView, ViewGroup parent) {
//ViewHolder holder;
if (convertView == null)
{
convertView = mInflater.inflate(R.layout.list_item, null);
Log.i("adapter", "ADAPTER");
}
checkTax = (CheckBox) convertView.findViewById(R.id.check_tax);
checkTax.setOnCheckedChangeListener(new OnCheckedChangeListener () {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Log.i("on click", "ON CLICK");
if (isChecked) {
tvSelectTaxAccount.setVisibility(View.VISIBLE);
spinnerTaxAcc.setVisibility(View.VISIBLE);
tvTaxAmt.setVisibility(View.VISIBLE);
editTaxAmt.setVisibility(View.VISIBLE);
tvAmtAfterTax.setVisibility(View.VISIBLE);
amtAfterTax.setVisibility(View.VISIBLE);
tvAmt.setText("amount before tax");
Log.i("checked", "CHECKED");
}
else
{
tvSelectTaxAccount.setVisibility(View.GONE);
spinnerTaxAcc.setVisibility(View.GONE);
tvTaxAmt.setVisibility(View.GONE);
editTaxAmt.setVisibility(View.GONE);
tvAmtAfterTax.setVisibility(View.GONE);
amtAfterTax.setVisibility(View.GONE);
tvAmt.setText("AMOUNT");
Log.i("unchecked", "UNCHECKED");
}
}
});
tvSelectTaxAccount = (TextView) convertView.findViewById(R.id.tv_select_tax_account);
spinnerTaxAcc = (Spinner) convertView.findViewById(R.id.spinner_tax_acc);
spinnerTaxAcc.setOnItemSelectedListener(selectSpinnerTaxAcc);
tvTaxAmt = (TextView) convertView.findViewById(R.id.tv_tax_amt);
editTaxAmt = (EditText) convertView.findViewById(R.id.edit_tax_amt);
tvAmt = (TextView) convertView.findViewById(R.id.tv_amt);
tvAmtAfterTax = (TextView) convertView.findViewById(R.id.tv_amt_after_tax);
amtAfterTax = (TextView) convertView.findViewById(R.id.amt_after_tax);
spinnerTaxAcc.setOnItemSelectedListener(selectSpinnerTaxAcc);
tvSelectTaxAccount.setVisibility(View.GONE);
spinnerTaxAcc.setVisibility(View.GONE);
tvTaxAmt.setVisibility(View.GONE);
editTaxAmt.setVisibility(View.GONE);
tvAmtAfterTax.setVisibility(View.GONE);
amtAfterTax.setVisibility(View.GONE);
return convertView;
}