Passing String From Edit Text To Another Activity
I have looked through the example here on stack overflow. However, I can't get a solution that works correctly. My application still crashes. How do I pass the string from an edit
Solution 1:
Change:
Intentintent=newIntent();
to:
Intent intent = newIntent(MyCurrentActivityClass.this, NextActivity.class);
Make sure NextActivity is in the Manifest. In the first case you're not providing enough info to start the activity.
Solution 2:
Try this:
From first activity send like this:
btnGo.setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(View v) {
// TODO Auto-generated method stubEditTextetLocation= (EditText) findViewById(R.id.et_location);
Intenti=newIntent(this, ActivityTwo.class);
i.putExtra("location", etLocation.getText().toString());
startActivity(i);
}
});
And in second activity do like this:
Intentin= getIntent();
String tv1= in.getExtras().getString("location");
textView1.setText(tv1);
Solution 3:
You should get your information from the second activity this way:
Bundleextras= getIntent().getExtras();
String myLocation= extras.getString("location");
Solution 4:
Did you declare a variable textview1? Change
textView1 = (TextView) findViewById(R.id.textView1); to
TextView textView1 = (TextView) findViewById(R.id.textView1);
Post a Comment for "Passing String From Edit Text To Another Activity"