i want to add intent in main activity -


You want to take the name of the person for the next activity and if the login is not ok, it will show the toast that it does not work And just show the toast. What should be included in the next activity and what is wrong with this code

  @Override protected void onCreate (bundled savedInstanceState) {super.onCreate (savedInstanceState ); SetContentView (R.layout.activity_main); Find the last edit text EText1 = (edit text) VVBID (RED Edit Text 1); Find the last edit text EText2 = (EditText) ViewById (R.id.editText2); Find the last button BTN1 = (button) VibibIID (R.B. button 1); . Btn1.setOnClickListener (New View.OnClickListener) {Public Zero onClick (see v) {String str = eText1.getText () toString (); String Log = "Malaica"; if (str == log) {intent = New intent (getApplicationContext (), FirstButton.class); intent.putExtra ("welcome", log in); else {toast TOS = Toast.makeText (getApplication (), "wrong", toast.LENGTH_SHORT); tos .show ();}}});    

First of all use par instead of == and to start a new activity

  if (str.equals) {intent = new intent (getApplicationContext (), FirstButton.class) ; Intent.putExtra ("welcome", log); // New Activity else {To start Toast TOS} = Toast.makeText (GetApplication; / * 'Welcome' will take your name from this activity for a key which suggests to change the FirstButton activity I * * / startActivity (intent) Is working as (), "wrong", toast.LENGTH_SHORT); Tos.show (); }   

and Firstboot activity you can get your name by

  intent I = getIntent (); String name = i.getStringExtra ("welcome");    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -