-1
我有一個listView與複選框。當checkBox被選中/取消選中時,它將統計和顯示button
delete
setText中的數字。如果計數器等於0,則它將只顯示DELETE
,否則將顯示DELETE (with the counter)
。但問題是刪除靜止的setText DELETE (with the counter)
雖然計數器爲0按鈕顯示覆選框計數器
holder.ckbox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (((CheckBox) v).isChecked()) {
int getPosition = (Integer) v.getTag(); // Here we get the position that we have set for the checkbox using setTag.
search.get(getPosition).setSelected(((CheckBox)v).isChecked()); // Set the value of checkbox to maintain its state.
checkBoxCounter ++;
delete.setText("DELETE"+""+"("+ checkBoxCounter +")");
} else
{
if(checkBoxCounter==0)
{
delete.setText("DELETE");
}
else {
int getPosition = (Integer) v.getTag(); // Here we get the position that we have set for the checkbox using setTag.
search.get(getPosition).setSelected(((CheckBox) v).isChecked()); // Set the value of checkbox to maintain its state.
checkBoxCounter--;
delete.setText("DELETE" + "" + "(" + checkBoxCounter + ")");
}
}
}
});
@Kathi ya..'private靜態INT checkBoxCounter = 0; ' – Hoo
@Kathi它仍然顯示DELETE(0) – Hoo