Android: (simple) missing import or...? -
i following book learn android , getting error, code
i using image above can see error (compoundbutton).
did type wrong or did book not write of imports needed?
thanks!
edited full code:
package newbook.appress; import android.app.activity; import android.os.bundle; import android.widget.checkbox; import android.widget.compoundbutton; public class checkboxdemo extends activity implements compoundbutton.oncheckchangedlistener{ checkbox cb; @override public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.main); cb=(checkbox)findviewbyid(r.id.chkbox1); cb.setoncheckedchangelistener(this); } public void oncheckedchanged(compoundbutton buttonview, boolean ischecked) { if (ischecked) { cb.settext("this checkbox is: checked"); } else { cb.settext("this checkbox is: unchecked"); } } }
that correct. need import everything. missing:
import android.widget.compoundbutton
you can type:
ctrlshift+o o rganize imports automatically in eclipse.
you'll want change second error to:
cb.setoncheckedchangelistener(this);
Comments
Post a Comment