//MainActivity
public class MainActivity extends Activity {
private EditText edit;
private Button button;
private TextView text;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
edit = (EditText) this.findViewById (R.id.eidt);
button = (Button) this.findViewById(R.id.but);
text = (TextView) this.findViewById(R.id.text);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
String s =edit.getText().toString().trim();
Intent intent = new Intent(MainActivity.this,FindEdit.class);
intent.putExtra("edit", s);
startActivityForResult(intent, 840626);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == 840626 && resultCode == 617724){
String a = data.getStringExtra("edit1").toString().trim();
text.setText(a);
}
}
}
//FindEdit
public class FindEdit extends Activity{
private EditText edit ;
private TextView text;
private Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.findedit_activity);
text = (TextView) findViewById (R.id.text);
edit = (EditText) findViewById (R.id.edit1);
button = (Button) findViewById (R.id.button);
Intent intent = getIntent();
String s = intent.getStringExtra("edit").toString().trim();
text.setText(s);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
String str = edit.getText().toString().trim();
Intent ent = new Intent();
ent.putExtra("edit1", str);
setResult(617724, ent);
finish();
}
});
}
}