My project\'s requirement is : edittext value is first entered by user and that same value will be visible in another activity\'s editext , which should be read only..
You can pass it using Intent's putExtra() method. try this way,
In First Activity,
Intent intent = new Intent ( FirstAcvity.this, SecondActivity.class );
intent.putExtra ( "TextBox", editText.getText().toString() );
startActivity(intent);
Now, in second activity, use following code,
Intent i = getIntent();
String text = i.getStringExtra ( "TextBox","" );
// Now set this value to EditText
secondEditText.setText ( text );
secondEditText.setEnable(false);
Hope this will help full for you.
This code for second activity where you want to show the Data from First Activity.
String mUrl = getIntent().getStringExtra("LinkingWord");
editTextURL.setText(getIntent().getStringExtra("LinkingWord"));
Don't forget to call EditText ID
EditText editTextURL = findViewById(R.id.edit_url);
Easy Peasy
HappyCoding
get the value of edit text by
String text = edit_text.getText.toString;
then pass it to other activity like
intent.putExtra("text", text);
In that activity get it onCreate through bundle like
Bundle extras = getExtra().getIntent();
String text = extras.getString("text");
now set this value in your edittext like
edit_text2.setText(text);
modify this code according to you.
Basically its not a big deal to pass edittext value to textview present in other activity just follow 2steps....
PROCESS
get two Activities(java classes)
in first Activity take editview
in second Activity take textview
dont forget to create a button and set Onclicklister to it
code the step2 in first activity inside button onclicklisten
now code the step3 in second activity
now run the code
((where "name" is indicated as a token to verify so maintain same char in both activities))
STEP1
1.Mainactivity.this//(Activity from where you should get the value)
EditText edittext=(EditText)findViewById(R.id.edittext);
Intent intent=new Intent(getApplicationContext(),Main2Activity.class);
intent.putExtra ( "name", ed1.getText().toString() );
startActivity(intent);
STEP2:
2.Main2activity//(Activity to where you should get the value)
Textview textview = (TextView) findViewById(R.id.textview);
Bundle bb;
bb=getIntent().getExtras();
textview.setText(bb.getString("name"));
Based on Lucifer's answer you could use a TextView in the second activity:
First Activity:
Intent intent = new Intent ( FirstAcvity.this, SecondActivity.class );
intent.putExtra ( "text", editText.getText().toString() );
startActivity(intent);
Second Activity:
Intent i = getIntent();
tv.setText(i.getStringExtra("text"); //tv is the TextView
public EditText var_name;
var_name=(EditText)findViewById(R.id.input_id);
publc void function_name(){
Intent i=new Intent(this, class_name.class);
String s=this.edittext_var_name.getString().toString();
i.putExtra("var_name","s");
startActivity(i);
}`