How To Send Multiple Edittexts In To Another Activity As A Textviews Like Login Page
There is Two Edit Texts Like Username and Password and one login Button..My Requirement is if we Enter user name and password are same or Different and press Button.Using Intent Th
Solution 1:
You need put them in Extras (putExtras) and then pass from the current activity to the other one.
You need capture your EditText value as String and then putExtra with Key - one each for your need and then retrieve them in the second activity.
You find on how to do this at - How to pass edit text data in form of string to next activity?
Solution 2:
Read text from EditText
:
EditTextet= (EditText) findViewById(R.id.edit_text);
Stringtext= et.getText().toString();
Pass it using Intent
:
Intent intent = newIntent(this, NewActivity.class);
intent.putExtra("textLabel", text);
startActivity(intent);
Read it in NewActivity
:
publicclassNewActivityextendsActivity {
@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
Intentintent= getIntent();
Stringstring= intent.getStringExtra("textLabel");
}
}
Solution 3:
See below code
EditTextet_username= (EditText) findViewById(R.id.edit_text1);
EditTextet_password= (EditText) findViewById(R.id.edit_text2);
Stringusername= et_username.getText().toString();
Stringpassword= et_password.getText().toString();
Now pass data at on click event in set below code.
Intent i = newIntent(this, Next.class);
i.putExtra("usename", username);
i.putExtra("password", password);
startActivity(i);
In next Activity in set below code:
publicclassNextextendsActivity {
String usename;
String password;
@OverrideprotectedvoidonCreate(...) {
...
Intenti= getIntent();
username= i.getStringExtra("username");
password= i.getStringExtra("password");
TextViewtv_username= (TextView ) findViewById(R.id.text_view1);
TextViewtv_password= (TextView ) findViewById(R.id.text_view2);
tv_username.setText(username.toString());
tv_username.setText(password.toString());
}
}
Post a Comment for "How To Send Multiple Edittexts In To Another Activity As A Textviews Like Login Page"