my list row contains a check box with some other views also. when i check or uncheck the checkbox, its associated action listener is not fired. Following is the code snippet for getView(). Please have a look and provide me with the solution.
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;
}
uncomment this line
//checkTax.setOnClickListener(tax);and try using a onclicklistener or try usingi think even setOnCheckedChangeListener will be fired on clicking a checkbox