-2
Good wondered, how can I add this (Intent) and how to print it at the end of the program in another Class.
public class Main2Activity extends AppCompatActivity implements View.OnClickListener{
int points = 0;
Button next;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
next = (Button) findViewById(R.id.next);
next.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.option1:
points = points + 0;
break;
case R.id.correctly:
points = points + 1;
break;
case R.id.option3:
points = points + 0;
break;
case R.id.option4:
points = points + 0;
break;
case R.id.option5:
points = points + 0;
break;
}
if (next.isPressed()) {
Intent intent = new Intent(this, Main3Activity.class);
intent.putExtra("pontuação", points);
startActivity(intent);
apply(intent);
}
}
}
Ola Gabriel,
– Um Programador
From what I understand, you must be doing some quests app and if the person hits the answer, sum with the points you already have and that score is taken to another Activity?
– Gabriel Heguedusch