我想在ListView
适配器中增加android计数器,但下一个单击行总是失败增加。
counting_update_cycle = actual.getJson().getCycle();
counting_update = counting_update_cycle;
holder.counting.setText(String.valueOf(counting_update_cycle));
//action tambah
holder.btntambahekekusi.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
holder.counting.setText(String.valueOf(counting_update));
counting_update++;
}
});
答案 0 :(得分:0)
请尝试以下代码:
counting_update_cycle = actual.getJson().getCycle();
counting_update = counting_update_cycle;
holder.counting.setText(String.valueOf(counting_update_cycle));
//action tambah
holder.btntambahekekusi.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// added code
counting_update_cycle = actual.getJson().getCycle();
counting_update = counting_update_cycle;
holder.counting.setText(String.valueOf(counting_update));
// update instance property of object
actual.getJson().setCycle(counting_update++);
}
});