android - How to know in which TableRow a CheckBox is placed -
i have tablelayout tablerows , checkbox , textview inside. when push checkbox need know in wich tablerow checkbox placed textview "associated" checkbox. example:
tablelayout:
- tablerow 1: x textview1
- tablerow 2: x textview2
- ...
i'm trying this:
cb.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { if (cb.ischecked()) { int id_cb = cb.getid(); boolean encontrado = false; (int = 0; < tabla_tareas.getchildcount() && !encontrado; i++) { tablerow aux_tr = (tablerow) tabla_tareas.getchildat(i); checkbox aux_cb = (checkbox) aux_tr.getchildat(0); if (id_cb == aux_cb.getid()) encontrado = true; }...
but doesn't work.
utilizing elior has said, why don't use folling methods achieve want:
cb.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { if (cb.ischecked()) { cb.gettext().tostring(); //this retrieve text associated checkbox cb.settext("your new string here"); //this set text associated checkbox }...
with above 2 methods should able need without need textview
, , without tablelayout
since assuming using align checkboxes
, textviews
.
Comments
Post a Comment