i have created survey layout question , can select below avg, avg or above avg. score @ bottom of page , updates on click via listener.
i have problem customer changing answer , not removing pervious value.
so below 1 , avg 2 , above 3. if click above adds 3 , change mind , want pick avg , click , adds 2 never removes pervious 3.
help
below32 = (checkbox) findviewbyid(r.id.below32); below32.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { if (below32.ischecked()) { sum += 1; double total = 100*sum/69; result.settext(string.format("%.1f", total) + "%"); avg32.setchecked(false); above32.setchecked(false); } else { sum -= 1; double total = 100*sum/69; result.settext(string.format("%.1f", total) + "%"); } } }); avg32 = (checkbox) findviewbyid(r.id.avg32); avg32.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { if (avg32.ischecked()) { sum += 2; double total = 100*sum/69; result.settext(string.format("%.1f", total) + "%"); below32.setchecked(false); above32.setchecked(false); } else { sum -= 2; double total = 100*sum/69; result.settext(string.format("%.1f", total) + "%"); } } }); above32 = (checkbox) findviewbyid(r.id.above32); above32.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { if (above32.ischecked()) { sum += 3; double total = 100*sum/69; result.settext(string.format("%.1f", total) + "%"); below32.setchecked(false); avg32.setchecked(false); } else { sum -= 3; double total = 100*sum/69; result.settext(string.format("%.1f", total) + "%"); } } });
what need change or make work? other attempts have failed.
Comments
Post a Comment