0

i got class Team and object name. I want to display the name in another activity in textView and i don't know how to do it. Can you help me? my code of class and object:

public class DruzynyStatActivity extends ActionBarActivity {
public class Team
{
    public String name;


}

...

public void cracovia(View view)
{
    Intent intent = new Intent(this, CracoviaActivity.class);
    startActivity(intent);
    Team cracovia= new Team();
    cracovia.name="Cracovia";
}
Adam M
  • 11
  • 3
  • 1
    possible duplicate of [how to pass string one activity to another?](http://stackoverflow.com/questions/6707900/how-to-pass-string-one-activity-to-another) – Willis Jan 20 '15 at 19:21

3 Answers3

1

You can use putExtra(..., ...) to pass values between activities.

See this other StackOverflow post

Community
  • 1
  • 1
1

You can pass the data over the intents. The code you are using on the button click is starting the next activity with passing parameter as intent.

 Intent intent = new Intent(this, CracoviaActivity.class);
 intent.putExtra("key","value");
 startActivity(intent);

Now on the another activity you can get this intent and the value by the key. as-

  Intent intent=getIntent()
  String received_value=intent.getStringExtra("key");

You can also add a Bundle object on the intent if you want to deal with more no of data.

Sanjeet A
  • 5,171
  • 3
  • 23
  • 40
0

This should do it:

public void cracovia(View view)
{
  Intent intent = new Intent(this, CracoviaActivity.class);
  Team cracovia= new Team();
  cracovia.name="Cracovia";
  name = cracovia.name;
  intent.putExtra("teamName", name);
  startActivity(intent);

}

Unless I am misunderstanding.

Joe C
  • 184
  • 1
  • 15