views:

15

answers:

1

Dear friends.

Can any one tell me how to pass the value of textview (if there are five value in textview and we pass only one) from one screen to its next screen. Consider the case: I'm having two screens, first screen with one textview and the second activity have one textview and button.

If I click the first value then it has to move to second activity textview.

A: 

In order to pass state information between screens, you need to first define your Intent which you will pass to startActivity(), then use the putExtra() method on the Intent to add extra information to it.

Intent i = new Intent();
i.setClassName("com.example", "com.example.newscreen");
i.putExtra("string1", "some string");
i.putExtra("string2", "some other string");
startActivity(i);

Now to get the values on the next screen, you'd do something like this:

Intent i = getIntent();
Bundle b = i.getExtras();
String string1 = b.getString("string1");
String string2 = b.getString("string2");
Tyler