There are three activites, when you click on the button in the first one, the value of the counter "1" is displayed in the field, the transition to the second Activiti also occurs, to which this value needs to be transferred (that is, "1" should be displayed in the second activit) press the button in the second activation, then in the third activation, the two should be displayed, etc. ... How to do it? Thank you in advance!
Tab1:
public class Tab1 extends Activity { ImageButton button1; int count = 0; TextView t; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tab1); button1 = (ImageButton)findViewById(R.id.button2); button1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent firstIntent = new Intent(Tab1.this, Tab2.class); startActivity(firstIntent); TextView t = (TextView)findViewById(R.id.t); t.setText("score: " + ++count +"/18"); finish(); } }); } }
Tab2:
public class Tab1 extends Activity { ImageButton button1; int count = 0; TextView t; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tab2); button1 = (ImageButton)findViewById(R.id.button2); button1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent firstIntent = new Intent(Tab1.this, Tab2.class); startActivity(firstIntent); TextView t = (TextView)findViewById(R.id.t); t.setText("score: " + ++count +"/18"); finish(); } }); } }
Tab3 looks the same.