android - Alert Dialog Message -
I am using a This is my code, Put the code in your second block. Hope That it is helpful update You are comparing two strings in your block which will be the cause of errors or if the condition is not true. See the following code correctly.You do not want the user to compare Code Change your status to it. if-else statement if the username and password are correct So it goes to the next activity but if they are wrong then I have to display a warning dialog message and when I click OK, I want to return to this login page. I appreciate some help *
import android.os.bundle; Import android App Import android.app.AlertDialog; Import android.content.DialogInterface; Import android.content.Intent; Import android.view.View; Import android.view.View.OnClickListener; Import android.widget.Button; Import android.widget.EditText; Public class main activity is expanding on the tools OnClickListener {button button; Private editing text is anonymous; Private editing text passw; String uson; String pass; Override public null on @reate (bundle saved instainstate) {super.naught (savedinstenstate); SetContentView (R.layout.activity_main); Button = (Button) findViewById (R.id.login); uname = (EditText) findViewById (R.id.username); passw = (EditText) findViewById (R.id.password); Button.setOnClickListener (this); } Click Public Zero (see V) {usern = uname.getText (). toString (); Pass = passw.getText (). ToString (); If ((uran == "exewies") & amp; (pass == "xyz")) {intent i = new intent (getApplicationContext (), TrackMap.class); startActivity (i); The code below has the code to implement the warning conversation in Android.}}}
New AlertDialog Builder (this) .setTitle ("Error"). Set permissions ("Wrong combination of username and password" + \ \ please try again) .setNeutralButton ("OK", New DialogInterface.OnClickListener () {Click on Public Zero (DialogInterface dialogue, int joe) {// This button will do nothing. This will only dismiss the dialog.}}) // You can set this icon by having an error image in your picture or the next line You can get rid of .setIcon (android.R.drawable.ic_dialog_alert). Show ();
== two strings, as
== does not compare the actual values and not the object In the
string category we call
equals () which is two strings Compares your position.
If (usern .equals ("xyz") & amp; (pass.equals ("xyz"))} {// add your code block here} < / Pre>
Comments
Post a Comment