Android: The method getId() in the type View is not applicable for the arguments (int) -


i trying access cb in if statement getting cb cant resolved

i have tried declare checkbox cb class variable getting the method getid() in type view not applicable arguments (int).

i tried declare method local variable final checkbox cb; getting 2 errors: first 1 the final local variable cb may have been assigned @ line cb = new checkbox(this); , second 1 the method getid() in type view not applicable arguments (int)

how can fix that?

private void createcheckboxlist(final arraylist<integer> items) {     //final checkbox cb;      final linearlayout ll = (linearlayout) findviewbyid(r.id.lila);     (int = 0; < items.size(); i++) {         checkbox cb = new checkbox(this);         cb.settext(string.valueof(items.get(i)));         cb.setid(i);         ll.addview(cb);      }     button btn = new button(this);     btn.setlayoutparams(new linearlayout.layoutparams(500, 150));     btn.settext("submit");     ll.addview(btn);      btn.setonclicklistener(new view.onclicklistener() {          @override         public void onclick(view v) {             (int : items) {                 if (cb.getid(i).ischecked()) {                  }             }          }     });  } 

  1. the reference cb wont exist outside 'for' loop. since know id can create new checkbox reference , use findviewbyid(); refer same checkbox

  2. cb.getid() returns , integer not checkbox reference

    final linearlayout ll = (linearlayout) findviewbyid(r.id.lila); (int = 0; < items.size(); i++) { final checkbox cb = new checkbox(this); cb.settext(string.valueof(items.get(i))); cb.setid(i); ll.addview(cb);  } button btn = new button(this); btn.setlayoutparams(new linearlayout.layoutparams(500, 150)); btn.settext("submit"); ll.addview(btn);  btn.setonclicklistener(new view.onclicklistener() {  @override public void onclick(view v) {     (int = 0; < items.size()) {   \\          checkbox ch=(checkbox) findviewbyid(i);  \\         if (ch.ischecked()) {          }     }  } });  } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -