Reputation: 1838
How should I get the text entered in an edittext and send that data to a different activity?
Example: If a user enters text in an EditText, and presses a submit button, I want to store the text entered in the EditText and show it in a different activity when that activity is active.
Upvotes: 0
Views: 1872
Reputation: 48
EditText
, with: getText()
https://developer.android.com/reference/android/widget/EditText.html#getText()2.Two ways you can send the data.
//Create the bundle
Bundle bundle = new Bundle();
//Add your data from getFactualResults method to bundle
bundle.putString("CONSTANT_NAME", EditText.getText);
//Add the bundle to the intent
browserIntent.putExtras(bundle);
startActivity(browserIntent);
In the other activity you should use:
Bundle bundle = getIntent().getExtras();
//Extract the data…
String value = bundle.getString("CONSTANT_NAME");
if (bundle.containsKey(MainActivity.CONSTANT_NAME)) {
....
}
Upvotes: 2