java - findViewById must be void but can't make it void -
i trying use findviewbyid in code, must void, wrong? don't want have method clickbutton if take out, says must void. there way can without changing in code?
import android.os.bundle; import android.app.activity; import android.app.notificationmanager; import android.view.menu; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.edittext; import android.widget.textview; import android.widget.togglebutton; public class loginworker extends activity implements onclicklistener{ button login; edittext user, pass; togglebutton repass; textview invail; private boolean savelogin = false; public void clickbutton() { login = (button) findviewbyid(r.id.bloginf); user = (edittext) findviewbyid(r.id.usernametf); pass = (edittext) findviewbyid(r.id.passwordtf); invail = (textview) findviewbyid(r.id.invalidinfo); repass = (togglebutton) findviewbyid(r.id.rememberlogintb); login.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { if(user.gettext().equals("parents")){ if(pass.gettext().equals("!saints")){ if(repass.ischecked()){ savelogin = true; setcontentview(r.layout.announcements); } }else if(!repass.ischecked()){ savelogin = false; setcontentview(r.layout.announcements); } }if(!user.gettext().equals("pie")){ invail.settext("invalid username , / or password!"); }if(!pass.gettext().equals("!pie")){ invail.settext("invalid username , / or password!"); } } }); } }
thanks time!
you missing oncreate
function seems. oncreate
called when activity starting. initialization should go. have above code have inside oncreate function. before going further should study activity lifecycle. i.e happens when activity created , in order functions called. tell how implement want. @vikram suggested tutorial start.
Comments
Post a Comment