I am developing an android application in which i have taken two buttons and one edit text box. i want to pass the data of edit text box in from of string to the next activi
After you have used setContentView(...)
you need to reference your EditText
and get the text such as...
EditText et = (EditText) findViewById(R.id.my_edit_text);
String theText = et.getText().toString();
To pass it to another Activity
you use an Intent
. Example...
Intent i = new Intent(this, MyNewActivity.class);
i.putExtra("text_label", theText);
startActivity(i);
In the new Activity (in onCreate()
), you get the Intent and retrieve the String...
public class MyNewActivity extends Activity {
String uriString;
@Override
protected void onCreate(...) {
...
Intent i = getIntent();
uriString = i.getStringExtra("text_label");
}
}