How can I make a password to open up a page using a button an edit Text box and if/else statement (Android) -
i trying make password page in android. using string password store password. ie string password = bob. using edittext box enter word , using if else statement check if password , edittext input correct. carry out function using button make check.
here code have made far
package com.example.explicitintent; import android.app.activity; import android.content.intent; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.edittext; import android.widget.toast; public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); ////////////////////////////////////////////////////////////// button invokingbuttons = (button) findviewbyid(r.id.button1); invokingbuttons.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub string password = "bob"; edittext myedittext = (edittext) findviewbyid(r.id.edittext); if(myedittext.equals(password)){ intent explicitintent = new intent(mainactivity.this,nextactivity.class); startactivity(explicitintent); }else{ toast.maketext(getapplicationcontext(), "this toast message!!! =)", toast.length_long).show (); } } }); }; };
replace
if(myedittext.equals(password)) with
if(myedittext.gettext().tostring().equals(password))
Comments
Post a Comment